From e7cdd8f02ce71399efcf69ac3b39ba290c3462e3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 10 Aug 2017 13:36:11 -0700 Subject: [PATCH] fs: Avoid non-idempotent code flow in ListBuckets() (#4798) Under the call flow ``` Readdir + | | | path-entry | | v StatDir ``` Existing code was written in a manner where say a bucket/top-level directory was indeed deleted between Readdir() and before StatDir() we would ignore certain errors. This is not a plausible situation and might not happen in almost all practical cases. We do not have to look for or interpret these errors returned by StatDir() instead we can just collect the successful values and return back to the client. We do not need to pre-maturely decide on bucket access we just let filesystem decide subsequently for real I/O operations. Refer #4658 --- cmd/fs-v1.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index bc5f233ba..96ce9f5f5 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -257,17 +257,14 @@ func (fs fsObjects) ListBuckets() ([]BucketInfo, error) { } var fi os.FileInfo fi, err = fsStatDir(pathJoin(fs.fsPath, entry)) + // There seems like no practical reason to check for errors + // at this point, if there are indeed errors we can simply + // just ignore such buckets and list only those which + // return proper Stat information instead. if err != nil { - // If the directory does not exist, skip the entry. - if errorCause(err) == errVolumeNotFound { - continue - } else if errorCause(err) == errVolumeAccessDenied { - // Skip the entry if its a file. - continue - } - return nil, err + // Ignore any errors returned here. + continue } - bucketInfos = append(bucketInfos, BucketInfo{ Name: fi.Name(), // As osStat() doesnt carry CreatedTime, use ModTime() as CreatedTime.