diff --git a/cmd/metacache-walk.go b/cmd/metacache-walk.go index 476e01f5a..6350179d3 100644 --- a/cmd/metacache-walk.go +++ b/cmd/metacache-walk.go @@ -258,7 +258,7 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ meta.name = strings.TrimSuffix(meta.name, globalDirSuffixWithSlash) + slashSeparator } out <- meta - case osIsNotExist(err): + case osIsNotExist(err), isSysErrIsDir(err): s.walkMu.Lock() meta.metadata, err = xioutil.ReadFile(pathJoin(volumeDir, meta.name, xlStorageFormatFileV1)) s.walkMu.Unlock() diff --git a/cmd/object-api-listobjects_test.go b/cmd/object-api-listobjects_test.go index b5d1f2a3e..474c1b862 100644 --- a/cmd/object-api-listobjects_test.go +++ b/cmd/object-api-listobjects_test.go @@ -88,6 +88,7 @@ func testListObjects(obj ObjectLayer, instanceType string, t1 TestErrHandler) { {testBuckets[5], "foo/201910/1112", "content", nil}, {testBuckets[5], "foo/201910/2112", "content", nil}, {testBuckets[5], "foo/201910_txt", "content", nil}, + {testBuckets[5], "201910/foo/bar/xl.meta/1.txt", "content", nil}, } for _, object := range testObjects { md5Bytes := md5.Sum([]byte(object.content)) @@ -499,6 +500,13 @@ func testListObjects(obj ObjectLayer, instanceType string, t1 TestErrHandler) { {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 { @@ -627,6 +635,8 @@ func testListObjects(obj ObjectLayer, instanceType string, t1 TestErrHandler) { // Test listing with prefix match {testBuckets[5], "foo/201910/11", "", "", 1000, resultCases[37], 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 { diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index b6cde37b6..dcb605a1f 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -34,6 +34,7 @@ import ( "runtime" "strings" "sync" + "syscall" "time" "github.com/dustin/go-humanize" @@ -405,6 +406,13 @@ func (s *xlStorage) readMetadata(itemPath string) ([]byte, error) { if err != nil { return nil, err } + if stat.IsDir() { + return nil, &os.PathError{ + Op: "open", + Path: itemPath, + Err: syscall.EISDIR, + } + } return readXLMetaNoData(f, stat.Size()) }