From 5b9342d35c7070eba801cef3bef1538b1b9cec91 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Thu, 19 Mar 2020 00:58:05 +0100 Subject: [PATCH] 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. --- cmd/xl-v1-list-objects.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/xl-v1-list-objects.go b/cmd/xl-v1-list-objects.go index fd8e5151c..8ccebafc1 100644 --- a/cmd/xl-v1-list-objects.go +++ b/cmd/xl-v1-list-objects.go @@ -34,14 +34,10 @@ func listDirFactory(ctx context.Context, disks ...StorageAPI) ListDirFunc { var newEntries []string var err error entries, err = disk.ListDir(bucket, prefixDir, -1, xlMetaJSONFile) - if err != nil { + if err != nil || len(entries) == 0 { continue } - if len(entries) == 0 { - return true, nil - } - // Find elements in entries which are not in mergedEntries for _, entry := range entries { idx := sort.SearchStrings(mergedEntries, entry) @@ -58,6 +54,11 @@ func listDirFactory(ctx context.Context, disks ...StorageAPI) ListDirFunc { sort.Strings(mergedEntries) } } + + if len(mergedEntries) == 0 { + return true, nil + } + return false, filterMatchingPrefix(mergedEntries, prefixEntry) } return listDir