From 7bf093c06ab05d27824037d3c2c0c6a4ad90d0be Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 18 Oct 2019 18:49:11 +0100 Subject: [PATCH] xl: Fix isObject() to consider not found disks (#8411) xl.isObject() returns 'nil' for not found disks when calculating the existance of xl.json for a given object, which what StatFile() is also doing (setting nil) if xl.json exists. This commit avoids this confusion by setting errDiskNotFound error when the storage disk is not found. --- cmd/xl-v1-common.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/xl-v1-common.go b/cmd/xl-v1-common.go index 0e5462993..9d3c8c64f 100644 --- a/cmd/xl-v1-common.go +++ b/cmd/xl-v1-common.go @@ -58,12 +58,13 @@ func (xl xlObjects) isObject(bucket, prefix string) (ok bool) { g := errgroup.WithNErrs(len(storageDisks)) - for index, disk := range storageDisks { - if disk == nil { - continue - } - index := index + for i := range storageDisks { + // Initialize a new index variable before passing to the goroutine + index := i g.Go(func() error { + if storageDisks[index] == nil { + return errDiskNotFound + } // Check if 'prefix' is an object on this 'disk', else continue the check the next disk fi, err := storageDisks[index].StatFile(bucket, pathJoin(prefix, xlMetaJSONFile)) if err != nil { @@ -73,7 +74,7 @@ func (xl xlObjects) isObject(bucket, prefix string) (ok bool) { return errCorruptedFormat } return nil - }, index) + }, i) } // NOTE: Observe we are not trying to read `xl.json` and figure out the actual