diff --git a/Duplicati/Library/Main/DatabaseLocator.cs b/Duplicati/Library/Main/DatabaseLocator.cs index d611673dbb..2dbd743d20 100644 --- a/Duplicati/Library/Main/DatabaseLocator.cs +++ b/Duplicati/Library/Main/DatabaseLocator.cs @@ -43,9 +43,32 @@ public static string GetDatabasePath(string backend, Options options, bool autoC options = new Options(new Dictionary()); if (!string.IsNullOrEmpty(options.Dbpath)) - return options.Dbpath; - - var folder = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Duplicati"); + return options.Dbpath; + + //Normal mode uses the systems "(Local) Application Data" folder + // %LOCALAPPDATA% on Windows, ~/.config on Linux + + // Special handling for Windows: + // - Older versions use %APPDATA% + // - but new versions use %LOCALAPPDATA% + // + // If we find a new version, lets use that + // otherwise use the older location + // + + var folder = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Duplicati"); + + if (Duplicati.Library.Utility.Utility.IsClientWindows) + { + var newlocation = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Duplicati"); + + var prevfile = System.IO.Path.Combine(folder, "dbconfig.json"); + var curfile = System.IO.Path.Combine(newlocation, "dbconfig.json"); + + if (System.IO.File.Exists(curfile) || !System.IO.File.Exists(prevfile)) + folder = newlocation; + } + if (!System.IO.Directory.Exists(folder)) System.IO.Directory.CreateDirectory(folder);