Skip to content

Commit

Permalink
Also use %LOCALAPPDATA% for storing the database and config for the c…
Browse files Browse the repository at this point in the history
…ommandline on Windows.

This fixes #2348
This adresses parts of #2222
  • Loading branch information
kenkendk committed Jun 27, 2017
1 parent 57b3eff commit 9433c34
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions Duplicati/Library/Main/DatabaseLocator.cs
Expand Up @@ -43,9 +43,32 @@ public static string GetDatabasePath(string backend, Options options, bool autoC
options = new Options(new Dictionary<string, string>());

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);

Expand Down

0 comments on commit 9433c34

Please sign in to comment.