Skip to content

Commit 65d122f

Browse files
committed
refactor: stores runtime data in ~/.sourcegit instead of ~/.local/share/SourceGit (#2088)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 8a5b024 commit 65d122f

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ You can download the latest stable from [Releases](https://github.com/sourcegit-
7272

7373
This software creates a folder, which is platform-dependent, to store user settings, downloaded avatars and crash logs.
7474

75-
| OS | PATH |
76-
|---------|-------------------------------------------------|
77-
| Windows | `%APPDATA%\SourceGit` |
78-
| Linux | `${HOME}/.local/share/SourceGit` |
79-
| macOS | `${HOME}/Library/Application Support/SourceGit` |
75+
| OS | PATH |
76+
|---------|-------------------------------------------|
77+
| Windows | `%APPDATA%\SourceGit` |
78+
| Linux | `~/.sourcegit` |
79+
| macOS | `~/Library/Application Support/SourceGit` |
8080

8181
> [!TIP]
8282
> * You can open this data storage directory from the main menu `Open Data Storage Directory`.

src/Native/Linux.cs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,23 @@ public string GetDataDir()
4444
return portableDir;
4545
}
4646

47-
// Gets the `$XDG_DATA_HOME` dir.
47+
// Runtime data dir: ~/.sourcegit
4848
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
49-
var dataHome = Path.Combine(home, ".local", "share");
50-
if (!Directory.Exists(dataHome))
51-
Directory.CreateDirectory(dataHome);
49+
var dataDir = Path.Combine(home, ".sourcegit");
50+
if (Directory.Exists(dataDir))
51+
return dataDir;
5252

53-
// Gets the data dir and migrate old data.
54-
var dataDir = Path.Combine(dataHome, "SourceGit");
55-
if (!Directory.Exists(dataDir))
53+
// Migrate old data: ~/.config/SourceGit
54+
var oldDataDir = Path.Combine(home, ".config", "SourceGit");
55+
if (Directory.Exists(oldDataDir))
5656
{
57-
var oldDataDir = Path.Combine(home, ".config", "SourceGit"); // Old data dir: $XDG_CONFIG_HOME/SourceGit
58-
var oldFallbackDir = Path.Combine(home, ".sourcegit"); // Old fallback folder: $HOME/.sourcegit
59-
var moveDir = Directory.Exists(oldDataDir)
60-
? oldDataDir
61-
: (Directory.Exists(oldFallbackDir) ? oldFallbackDir : string.Empty);
62-
63-
if (!string.IsNullOrEmpty(moveDir))
57+
try
58+
{
59+
Directory.Move(oldDataDir, dataDir);
60+
}
61+
catch
6462
{
65-
try
66-
{
67-
Directory.Move(moveDir, dataDir);
68-
}
69-
catch
70-
{
71-
// Ignore errors
72-
}
63+
// Ignore errors
7364
}
7465
}
7566

0 commit comments

Comments
 (0)