mirror of
https://github.com/minio/minio.git
synced 2025-04-23 20:05:55 -04:00
fix: check for xl.meta as directory fallback (#13023)
Objects uploaded in this format for example ``` mc cp /etc/hosts alias/bucket/foo/bar/xl.meta mc ls -r alias/bucket/foo/bar ``` Won't list the object, handle this scenario.
This commit is contained in:
parent
16f7c64a9f
commit
0f01e7ef0f
@ -258,7 +258,7 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ
|
|||||||
meta.name = strings.TrimSuffix(meta.name, globalDirSuffixWithSlash) + slashSeparator
|
meta.name = strings.TrimSuffix(meta.name, globalDirSuffixWithSlash) + slashSeparator
|
||||||
}
|
}
|
||||||
out <- meta
|
out <- meta
|
||||||
case osIsNotExist(err):
|
case osIsNotExist(err), isSysErrIsDir(err):
|
||||||
s.walkMu.Lock()
|
s.walkMu.Lock()
|
||||||
meta.metadata, err = xioutil.ReadFile(pathJoin(volumeDir, meta.name, xlStorageFormatFileV1))
|
meta.metadata, err = xioutil.ReadFile(pathJoin(volumeDir, meta.name, xlStorageFormatFileV1))
|
||||||
s.walkMu.Unlock()
|
s.walkMu.Unlock()
|
||||||
|
@ -88,6 +88,7 @@ func testListObjects(obj ObjectLayer, instanceType string, t1 TestErrHandler) {
|
|||||||
{testBuckets[5], "foo/201910/1112", "content", nil},
|
{testBuckets[5], "foo/201910/1112", "content", nil},
|
||||||
{testBuckets[5], "foo/201910/2112", "content", nil},
|
{testBuckets[5], "foo/201910/2112", "content", nil},
|
||||||
{testBuckets[5], "foo/201910_txt", "content", nil},
|
{testBuckets[5], "foo/201910_txt", "content", nil},
|
||||||
|
{testBuckets[5], "201910/foo/bar/xl.meta/1.txt", "content", nil},
|
||||||
}
|
}
|
||||||
for _, object := range testObjects {
|
for _, object := range testObjects {
|
||||||
md5Bytes := md5.Sum([]byte(object.content))
|
md5Bytes := md5.Sum([]byte(object.content))
|
||||||
@ -499,6 +500,13 @@ func testListObjects(obj ObjectLayer, instanceType string, t1 TestErrHandler) {
|
|||||||
{Name: "foo/201910_txt"},
|
{Name: "foo/201910_txt"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// ListObjectsResult-39 list with prefix match 1 level deep
|
||||||
|
{
|
||||||
|
IsTruncated: false,
|
||||||
|
Objects: []ObjectInfo{
|
||||||
|
{Name: "201910/foo/bar/xl.meta/1.txt"},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -627,6 +635,8 @@ func testListObjects(obj ObjectLayer, instanceType string, t1 TestErrHandler) {
|
|||||||
// Test listing with prefix match
|
// Test listing with prefix match
|
||||||
{testBuckets[5], "foo/201910/11", "", "", 1000, resultCases[37], nil, true},
|
{testBuckets[5], "foo/201910/11", "", "", 1000, resultCases[37], nil, true},
|
||||||
{testBuckets[5], "foo/201910", "", "", 1000, resultCases[38], nil, true},
|
{testBuckets[5], "foo/201910", "", "", 1000, resultCases[38], nil, true},
|
||||||
|
// Test listing with prefix match with 'xl.meta'
|
||||||
|
{testBuckets[5], "201910/foo/bar", "", "", 1000, resultCases[39], nil, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
|
@ -34,6 +34,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
@ -405,6 +406,13 @@ func (s *xlStorage) readMetadata(itemPath string) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if stat.IsDir() {
|
||||||
|
return nil, &os.PathError{
|
||||||
|
Op: "open",
|
||||||
|
Path: itemPath,
|
||||||
|
Err: syscall.EISDIR,
|
||||||
|
}
|
||||||
|
}
|
||||||
return readXLMetaNoData(f, stat.Size())
|
return readXLMetaNoData(f, stat.Size())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user