mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 05:33:11 +08:00
Use a stable sort for sorting directory entries
This is useful if there are duplicates. Assuming the remote delivers the entries in a consistent order, this will give the best user experience in syncing as it will consistently use the first entry for the sync comparison.
This commit is contained in:
parent
27b157580e
commit
69ff009264
|
@ -630,8 +630,14 @@ func ListDirSorted(fs Fs, includeAll bool, dir string) (entries DirEntries, err
|
|||
entries = newEntries
|
||||
}
|
||||
|
||||
// sort the directory entries by Remote
|
||||
sort.Sort(entries)
|
||||
// Sort the directory entries by Remote
|
||||
//
|
||||
// We use a stable sort here just in case there are
|
||||
// duplicates. Assuming the remote delivers the entries in a
|
||||
// consistent order, this will give the best user experience
|
||||
// in syncing as it will use the first entry for the sync
|
||||
// comparison.
|
||||
sort.Stable(entries)
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ func (dt DirTree) checkParents(root string) {
|
|||
// Sort sorts all the Entries
|
||||
func (dt DirTree) Sort() {
|
||||
for _, entries := range dt {
|
||||
sort.Sort(entries)
|
||||
sort.Stable(entries)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,6 @@ func walkR(f Fs, path string, includeAll bool, maxLevel int, fn WalkFunc, listR
|
|||
if entries == nil {
|
||||
entries = emptyDir
|
||||
}
|
||||
sort.Sort(entries)
|
||||
err = fn(dirPath, entries, nil)
|
||||
if err == ErrorSkipDir {
|
||||
skipping = true
|
||||
|
|
Loading…
Reference in New Issue
Block a user