mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 05:10:25 +08:00
refactor: stores runtime data in ~/.sourcegit instead of ~/.local/share/SourceGit (#2088)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
10
README.md
10
README.md
@@ -72,11 +72,11 @@ You can download the latest stable from [Releases](https://github.com/sourcegit-
|
||||
|
||||
This software creates a folder, which is platform-dependent, to store user settings, downloaded avatars and crash logs.
|
||||
|
||||
| OS | PATH |
|
||||
|---------|-------------------------------------------------|
|
||||
| Windows | `%APPDATA%\SourceGit` |
|
||||
| Linux | `${HOME}/.local/share/SourceGit` |
|
||||
| macOS | `${HOME}/Library/Application Support/SourceGit` |
|
||||
| OS | PATH |
|
||||
|---------|-------------------------------------------|
|
||||
| Windows | `%APPDATA%\SourceGit` |
|
||||
| Linux | `~/.sourcegit` |
|
||||
| macOS | `~/Library/Application Support/SourceGit` |
|
||||
|
||||
> [!TIP]
|
||||
> * You can open this data storage directory from the main menu `Open Data Storage Directory`.
|
||||
|
||||
@@ -44,32 +44,23 @@ namespace SourceGit.Native
|
||||
return portableDir;
|
||||
}
|
||||
|
||||
// Gets the `$XDG_DATA_HOME` dir.
|
||||
// Runtime data dir: ~/.sourcegit
|
||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
var dataHome = Path.Combine(home, ".local", "share");
|
||||
if (!Directory.Exists(dataHome))
|
||||
Directory.CreateDirectory(dataHome);
|
||||
var dataDir = Path.Combine(home, ".sourcegit");
|
||||
if (Directory.Exists(dataDir))
|
||||
return dataDir;
|
||||
|
||||
// Gets the data dir and migrate old data.
|
||||
var dataDir = Path.Combine(dataHome, "SourceGit");
|
||||
if (!Directory.Exists(dataDir))
|
||||
// Migrate old data: ~/.config/SourceGit
|
||||
var oldDataDir = Path.Combine(home, ".config", "SourceGit");
|
||||
if (Directory.Exists(oldDataDir))
|
||||
{
|
||||
var oldDataDir = Path.Combine(home, ".config", "SourceGit"); // Old data dir: $XDG_CONFIG_HOME/SourceGit
|
||||
var oldFallbackDir = Path.Combine(home, ".sourcegit"); // Old fallback folder: $HOME/.sourcegit
|
||||
var moveDir = Directory.Exists(oldDataDir)
|
||||
? oldDataDir
|
||||
: (Directory.Exists(oldFallbackDir) ? oldFallbackDir : string.Empty);
|
||||
|
||||
if (!string.IsNullOrEmpty(moveDir))
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Move(moveDir, dataDir);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
Directory.Move(oldDataDir, dataDir);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user