From dee7eb87d97c44db85dc9f3cfa9cd76dad671d8a Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 3 Feb 2015 23:48:48 +0100 Subject: [PATCH] Added logic to handle inputs with multiple of the same source folders. This fixes #1269. --- Duplicati/Server/SpecialFolders.cs | 49 ++++++++++++++++++------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/Duplicati/Server/SpecialFolders.cs b/Duplicati/Server/SpecialFolders.cs index dd470a406..1ae5f8779 100644 --- a/Duplicati/Server/SpecialFolders.cs +++ b/Duplicati/Server/SpecialFolders.cs @@ -114,28 +114,39 @@ namespace Duplicati.Server { var systemIO = Duplicati.Library.Snapshots.SnapshotUtility.SystemIO; - return backup.Sources.Distinct().Select(x => { - var sp = SpecialFolders.TranslateToDisplayString(x); - if (sp != null) - return new KeyValuePair(x, sp); + var sources = backup.Sources.Distinct().Select(x => + { + var sp = SpecialFolders.TranslateToDisplayString(x); + if (sp != null) + return new KeyValuePair(x, sp); - x = SpecialFolders.ExpandEnvironmentVariables(x); - try { - var nx = x; - if (nx.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) - nx = nx.Substring(0, nx.Length - 1); - var n = systemIO.PathGetFileName(nx); - if (!string.IsNullOrWhiteSpace(n)) - return new KeyValuePair(x, n); - } catch { - } + x = SpecialFolders.ExpandEnvironmentVariables(x); + try + { + var nx = x; + if (nx.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) + nx = nx.Substring(0, nx.Length - 1); + var n = systemIO.PathGetFileName(nx); + if (!string.IsNullOrWhiteSpace(n)) + return new KeyValuePair(x, n); + } + catch + { + } - if (x.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && x.Length > 1) - return new KeyValuePair(x, x.Substring(0, x.Length - 1).Substring(x.Substring(0, x.Length - 1).LastIndexOf("/") + 1)); - else - return new KeyValuePair(x, x); + if (x.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && x.Length > 1) + return new KeyValuePair(x, x.Substring(0, x.Length - 1).Substring(x.Substring(0, x.Length - 1).LastIndexOf("/") + 1)); + else + return new KeyValuePair(x, x); - }).ToDictionary(x => x.Key, x => x.Value); + }); + + // Handle duplicates + var result = new Dictionary(); + foreach(var x in sources) + result[x.Key] = x.Value; + + return result; } } }