mirror of
https://github.com/minio/minio.git
synced 2025-11-10 05:59:43 -05:00
cleanup: refactor common code between FS and XL listDirFactory. (#3639)
This commit is contained in:
committed by
Harshavardhana
parent
8e49a3d047
commit
17dd1c19df
36
cmd/fs-v1.go
36
cmd/fs-v1.go
@@ -731,37 +731,11 @@ func (fs fsObjects) listDirFactory(isLeaf isLeafFunc) listDirFunc {
|
||||
// listDir - lists all the entries at a given prefix and given entry in the prefix.
|
||||
listDir := func(bucket, prefixDir, prefixEntry string) (entries []string, delayIsLeaf bool, err error) {
|
||||
entries, err = readDir(pathJoin(fs.fsPath, bucket, prefixDir))
|
||||
if err == nil {
|
||||
// Listing needs to be sorted.
|
||||
sort.Strings(entries)
|
||||
|
||||
// Filter entries that have the prefix prefixEntry.
|
||||
entries = filterMatchingPrefix(entries, prefixEntry)
|
||||
|
||||
// Can isLeaf() check be delayed till when it has to be sent down the
|
||||
// treeWalkResult channel?
|
||||
delayIsLeaf = delayIsLeafCheck(entries)
|
||||
if delayIsLeaf {
|
||||
return entries, delayIsLeaf, nil
|
||||
}
|
||||
|
||||
// isLeaf() check has to happen here so that trailing "/" for objects can be removed.
|
||||
for i, entry := range entries {
|
||||
if isLeaf(bucket, pathJoin(prefixDir, entry)) {
|
||||
entries[i] = strings.TrimSuffix(entry, slashSeparator)
|
||||
}
|
||||
}
|
||||
|
||||
// Sort again after removing trailing "/" for objects as the previous sort
|
||||
// does not hold good anymore.
|
||||
sort.Strings(entries)
|
||||
|
||||
// Succes.
|
||||
return entries, delayIsLeaf, nil
|
||||
} // Return error at the end.
|
||||
|
||||
// Error.
|
||||
return nil, false, err
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
entries, delayIsLeaf = filterListEntries(bucket, prefixDir, entries, prefixEntry, isLeaf)
|
||||
return entries, delayIsLeaf, nil
|
||||
}
|
||||
|
||||
// Return list factory instance.
|
||||
|
||||
Reference in New Issue
Block a user