Added logic to handle inputs with multiple of the same source folders.

This fixes #1269.
This commit is contained in:
Kenneth Skovhede
2015-02-03 23:48:48 +01:00
parent 60389b1e6e
commit dee7eb87d9
+30 -19
View File
@@ -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<string, string>(x, sp);
var sources = backup.Sources.Distinct().Select(x =>
{
var sp = SpecialFolders.TranslateToDisplayString(x);
if (sp != null)
return new KeyValuePair<string, string>(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<string, string>(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<string, string>(x, n);
}
catch
{
}
if (x.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && x.Length > 1)
return new KeyValuePair<string, string>(x, x.Substring(0, x.Length - 1).Substring(x.Substring(0, x.Length - 1).LastIndexOf("/") + 1));
else
return new KeyValuePair<string, string>(x, x);
if (x.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && x.Length > 1)
return new KeyValuePair<string, string>(x, x.Substring(0, x.Length - 1).Substring(x.Substring(0, x.Length - 1).LastIndexOf("/") + 1));
else
return new KeyValuePair<string, string>(x, x);
}).ToDictionary(x => x.Key, x => x.Value);
});
// Handle duplicates
var result = new Dictionary<string, string>();
foreach(var x in sources)
result[x.Key] = x.Value;
return result;
}
}
}