xl: Tree walking should not quit when one disk returns empty (#9160)

Currently, a tree walking, needed to a list objects in a specific
set quits listing as long as it finds no entries in a disk, which
is wrong.

This affected background healing, because the latter is using
tree walk directly. If one object does not exist in the first
disk for example, it will be seemed like the object does not
exist at all and no healing work is needed.

This commit fixes the behavior.
master
Anis Elleuch 5 years ago committed by GitHub
parent 8d98662633
commit 5b9342d35c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      cmd/xl-v1-list-objects.go

@ -34,14 +34,10 @@ func listDirFactory(ctx context.Context, disks ...StorageAPI) ListDirFunc {
var newEntries []string var newEntries []string
var err error var err error
entries, err = disk.ListDir(bucket, prefixDir, -1, xlMetaJSONFile) entries, err = disk.ListDir(bucket, prefixDir, -1, xlMetaJSONFile)
if err != nil { if err != nil || len(entries) == 0 {
continue continue
} }
if len(entries) == 0 {
return true, nil
}
// Find elements in entries which are not in mergedEntries // Find elements in entries which are not in mergedEntries
for _, entry := range entries { for _, entry := range entries {
idx := sort.SearchStrings(mergedEntries, entry) idx := sort.SearchStrings(mergedEntries, entry)
@ -58,6 +54,11 @@ func listDirFactory(ctx context.Context, disks ...StorageAPI) ListDirFunc {
sort.Strings(mergedEntries) sort.Strings(mergedEntries)
} }
} }
if len(mergedEntries) == 0 {
return true, nil
}
return false, filterMatchingPrefix(mergedEntries, prefixEntry) return false, filterMatchingPrefix(mergedEntries, prefixEntry)
} }
return listDir return listDir

Loading…
Cancel
Save