From 14ef4437e52d51a8b28d419f1b79b61a93701b7a Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 17 Mar 2019 10:44:32 +0000 Subject: [PATCH] dedupe: fix bug introduced when converting to use walk.ListR #2902 Before the fix we were only de-duping the ListR batches. Afterwards we dedupe everything. This will have the consequence that rclone uses more memory as it will build a map of all the directory names, not just the names in a given directory. --- fs/operations/dedupe.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/operations/dedupe.go b/fs/operations/dedupe.go index 081df9892..110e3b6b2 100644 --- a/fs/operations/dedupe.go +++ b/fs/operations/dedupe.go @@ -191,22 +191,22 @@ var _ pflag.Value = (*DeduplicateMode)(nil) // dedupeFindDuplicateDirs scans f for duplicate directories func dedupeFindDuplicateDirs(f fs.Fs) ([][]fs.Directory, error) { - duplicateDirs := [][]fs.Directory{} + dirs := map[string][]fs.Directory{} err := walk.ListR(f, "", true, fs.Config.MaxDepth, walk.ListDirs, func(entries fs.DirEntries) error { - dirs := map[string][]fs.Directory{} entries.ForDir(func(d fs.Directory) { dirs[d.Remote()] = append(dirs[d.Remote()], d) }) - for _, ds := range dirs { - if len(ds) > 1 { - duplicateDirs = append(duplicateDirs, ds) - } - } return nil }) if err != nil { return nil, errors.Wrap(err, "find duplicate dirs") } + duplicateDirs := [][]fs.Directory{} + for _, ds := range dirs { + if len(ds) > 1 { + duplicateDirs = append(duplicateDirs, ds) + } + } return duplicateDirs, nil }