diff options
author | Kenneth Skovhede <kenneth@hexad.dk> | 2016-10-14 13:52:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 13:52:33 +0300 |
commit | 737976c834f6eab0390ffe2e1200b43b444c21d0 (patch) | |
tree | 3e1a20054c9ed7c1232f5dc17786e4f2087a1dae | |
parent | bc55763339a44a26c9714b8ad2af03fe97c230e6 (diff) | |
parent | f042a460767ab29b00b924b739adede664c7a25e (diff) |
Merge pull request #2011 from duplicati/feature/work_on_homedir_windows
Additional workarounds to support variations in the Windows "Home" folder.
This should solve #1913 or at least add enough information that it can be fixed.
-rw-r--r-- | Duplicati/Library/Utility/FilterExpression.cs | 15 | ||||
-rw-r--r-- | Duplicati/Server/SpecialFolders.cs | 42 | ||||
-rw-r--r-- | Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs | 1 |
3 files changed, 38 insertions, 20 deletions
diff --git a/Duplicati/Library/Utility/FilterExpression.cs b/Duplicati/Library/Utility/FilterExpression.cs index 07789fe65..8bf2a1529 100644 --- a/Duplicati/Library/Utility/FilterExpression.cs +++ b/Duplicati/Library/Utility/FilterExpression.cs @@ -379,15 +379,16 @@ namespace Duplicati.Library.Utility includes = false;
excludes = false;
- Tuple<bool, bool> cacheLookup;
+ Tuple<bool, bool> cacheLookup = null;
// Check for cached results
- lock(_matchLock)
- if (_matchFallbackLookup.TryGetValue(filter, out cacheLookup))
- {
- includes = cacheLookup.Item1;
- excludes = cacheLookup.Item2;
- }
+ if (filter != null)
+ lock(_matchLock)
+ if (_matchFallbackLookup.TryGetValue(filter, out cacheLookup))
+ {
+ includes = cacheLookup.Item1;
+ excludes = cacheLookup.Item2;
+ }
// Figure out what components are in the filter
if (cacheLookup == null)
diff --git a/Duplicati/Server/SpecialFolders.cs b/Duplicati/Server/SpecialFolders.cs index 802897e79..52285b865 100644 --- a/Duplicati/Server/SpecialFolders.cs +++ b/Duplicati/Server/SpecialFolders.cs @@ -30,7 +30,8 @@ namespace Duplicati.Server public static string ExpandEnvironmentVariables(string path)
{
foreach(var n in Nodes)
- path = path.Replace(n.id, n.resolvedpath);
+ if (path.StartsWith(n.id))
+ path = path.Replace(n.id, n.resolvedpath);
return Library.Utility.Utility.ExpandEnvironmentVariables(path);
}
@@ -84,18 +85,22 @@ namespace Duplicati.Server {
try
{
- if (System.IO.Path.IsPathRooted(folder) && System.IO.Directory.Exists(folder))
+ if (!string.IsNullOrWhiteSpace(folder) && System.IO.Path.IsPathRooted(folder) && System.IO.Directory.Exists(folder))
{
- lst.Add(new Serializable.TreeNode() {
- id = id,
- text = display,
- leaf = false,
- iconCls = "x-tree-icon-special",
- resolvedpath = folder
- });
-
- PathMap[id] = folder;
- DisplayMap[id] = display;
+ if (!PathMap.ContainsKey(id))
+ {
+ lst.Add(new Serializable.TreeNode()
+ {
+ id = id,
+ text = display,
+ leaf = false,
+ iconCls = "x-tree-icon-special",
+ resolvedpath = folder
+ });
+
+ PathMap[id] = folder;
+ DisplayMap[id] = display;
+ }
}
}
catch
@@ -107,7 +112,7 @@ namespace Duplicati.Server {
var lst = new List<Serializable.TreeNode>();
- if (!Library.Utility.Utility.IsClientLinux)
+ if (Library.Utility.Utility.IsClientWindows)
{
TryAdd(lst, Environment.SpecialFolder.MyDocuments, "%MY_DOCUMENTS%", "My Documents");
TryAdd(lst, Environment.SpecialFolder.MyMusic, "%MY_MUSIC%", "My Music");
@@ -116,6 +121,16 @@ namespace Duplicati.Server TryAdd(lst, Environment.SpecialFolder.DesktopDirectory, "%DESKTOP%", "Desktop");
TryAdd(lst, Environment.SpecialFolder.ApplicationData, "%APPDATA%", "Application Data");
TryAdd(lst, Environment.SpecialFolder.UserProfile, "%HOME%", "Home");
+
+ try
+ {
+ // In case the UserProfile member points to junk
+ TryAdd(lst, System.IO.Path.Combine(Environment.GetEnvironmentVariable("HOMEDRIVE"), Environment.GetEnvironmentVariable("HOMEPATH")), "%HOME%", "Home");
+ }
+ catch
+ {
+ }
+
}
else
{
@@ -123,6 +138,7 @@ namespace Duplicati.Server TryAdd(lst, Environment.SpecialFolder.MyMusic, "%MY_MUSIC%", "My Music");
TryAdd(lst, Environment.SpecialFolder.MyPictures, "%MY_PICTURES%", "My Pictures");
TryAdd(lst, Environment.SpecialFolder.DesktopDirectory, "%DESKTOP%", "Desktop");
+ TryAdd(lst, Environment.GetEnvironmentVariable("HOME"), "%HOME%", "Home");
TryAdd(lst, Environment.SpecialFolder.Personal, "%HOME%", "Home");
}
diff --git a/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs b/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs index b1ca474d6..6b6169ca0 100644 --- a/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs +++ b/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs @@ -100,6 +100,7 @@ namespace Duplicati.Server.WebServer.RESTMethods UsingAlternateUpdateURLs = Duplicati.Library.AutoUpdater.AutoUpdateSettings.UsesAlternateURLs,
LogLevels = Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType)),
SuppressDonationMessages = Duplicati.Library.Main.Utility.SuppressDonationMessages,
+ SpecialFolders = from n in SpecialFolders.Nodes select new { ID = n.id, Path = n.resolvedpath },
BrowserLocale = new
{
Code = browserlanguage.Name,
|