Added logic to handle inputs with multiple of the same source folders.
This fixes #1269.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user