From d2adde730ab33e13e380d72b5030663cb07834e1 Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Fri, 22 Sep 2017 22:05:38 -0700 Subject: [PATCH] Use simpler data structures to detect duplicate filenames. A Dictionary is unnecessary since we don't have any key-value pairs. We just need to keep track of a unique collection of filenames. --- .../Library/Main/Operation/FilelistProcessor.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Duplicati/Library/Main/Operation/FilelistProcessor.cs b/Duplicati/Library/Main/Operation/FilelistProcessor.cs index d1a07875a..5c78ff800 100644 --- a/Duplicati/Library/Main/Operation/FilelistProcessor.cs +++ b/Duplicati/Library/Main/Operation/FilelistProcessor.cs @@ -101,19 +101,17 @@ namespace Duplicati.Library.Main.Operation throw new Duplicati.Library.Interface.UserInformationException(s); } - var lookup = new Dictionary(); - var doubles = new Dictionary(); + var lookup = new HashSet(); + var doubles = new HashSet(); foreach(var v in tp.ParsedVolumes) { - if (lookup.ContainsKey(v.File.Name)) - doubles[v.File.Name] = null; - else - lookup[v.File.Name] = null; + if (!lookup.Add(v.File.Name)) + doubles.Add(v.File.Name); } if (doubles.Count > 0) { - var s = string.Format("Found remote files reported as duplicates, either the backend module is broken or you need to manually remove the extra copies.\nThe following files were found multiple times: {0}", string.Join(", ", doubles.Keys)); + var s = string.Format("Found remote files reported as duplicates, either the backend module is broken or you need to manually remove the extra copies.\nThe following files were found multiple times: {0}", string.Join(", ", doubles)); log.AddError(s, null); throw new Duplicati.Library.Interface.UserInformationException(s); }