From 2393a3a0be75af09bc1b98a9f39b5d7614238e38 Mon Sep 17 00:00:00 2001 From: karthic rao Date: Mon, 2 May 2016 11:46:44 +0530 Subject: [PATCH] XL non-recursive fix (#1450) --- xl-objects.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/xl-objects.go b/xl-objects.go index c42afcaf7..b830bda15 100644 --- a/xl-objects.go +++ b/xl-objects.go @@ -296,35 +296,33 @@ func (xl xlObjects) ListObjects(bucket, prefix, marker, delimiter string, maxKey for _, fileInfo := range fileInfos { // FIXME: use fileInfo.Mode.IsDir() instead after fixing the bug in // XL listing which is not reseting the Mode to 0 for leaf dirs. - if strings.HasSuffix(fileInfo.Name, slashSeparator) { - if isLeafDirectory(xl.storage, bucket, fileInfo.Name) { - fileInfo.Name = strings.TrimSuffix(fileInfo.Name, slashSeparator) - // Set the Mode to a "regular" file. + if strings.HasSuffix(fileInfo.Name, slashSeparator) && isLeafDirectory(xl.storage, bucket, fileInfo.Name) { + // Set the Mode to a "regular" file. + var info MultipartObjectInfo + info, err = xl.getMultipartObjectInfo(bucket, fileInfo.Name) + if err == nil { fileInfo.Mode = 0 - var info MultipartObjectInfo - info, err = xl.getMultipartObjectInfo(bucket, fileInfo.Name) - if err != nil { - return ListObjectsInfo{}, toObjectErr(err, bucket) - } + + fileInfo.Name = strings.TrimSuffix(fileInfo.Name, slashSeparator) fileInfo.Size = info.GetSize() - allFileInfos = append(allFileInfos, fileInfo) - maxKeys-- - continue + } else if err != errFileNotFound { + return ListObjectsInfo{}, toObjectErr(err, bucket, fileInfo.Name) } - } - if strings.HasSuffix(fileInfo.Name, multipartMetaFile) { + allFileInfos = append(allFileInfos, fileInfo) + maxKeys-- + continue + } else if strings.HasSuffix(fileInfo.Name, multipartMetaFile) { fileInfo.Name = path.Dir(fileInfo.Name) var info MultipartObjectInfo info, err = xl.getMultipartObjectInfo(bucket, fileInfo.Name) if err != nil { - return ListObjectsInfo{}, toObjectErr(err, bucket) + return ListObjectsInfo{}, toObjectErr(err, bucket, fileInfo.Name) } fileInfo.Size = info.GetSize() allFileInfos = append(allFileInfos, fileInfo) maxKeys-- continue - } - if strings.HasSuffix(fileInfo.Name, multipartSuffix) { + } else if strings.HasSuffix(fileInfo.Name, multipartSuffix) { continue } allFileInfos = append(allFileInfos, fileInfo)