mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
fix: Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
returns an empty string on some linux distro
* fallback the storage folder to `~/.sourcegit`
This commit is contained in:
parent
9561f7ef64
commit
38665a61cb
3 changed files with 20 additions and 9 deletions
10
README.md
10
README.md
|
@ -45,11 +45,11 @@ You can download the latest stable from [Releases](https://github.com/sourcegit-
|
|||
|
||||
This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationData}/SourceGit"`, which is platform-dependent, to store user settings, downloaded avatars and crash logs.
|
||||
|
||||
| OS | PATH |
|
||||
|---------|-------------------------------------------------|
|
||||
| Windows | `C:\Users\USER_NAME\AppData\Roaming\SourceGit` |
|
||||
| Linux | `${HOME}/.config/SourceGit` |
|
||||
| macOS | `${HOME}/Library/Application Support/SourceGit` |
|
||||
| OS | PATH |
|
||||
|---------|-----------------------------------------------------|
|
||||
| Windows | `C:\Users\USER_NAME\AppData\Roaming\SourceGit` |
|
||||
| Linux | `${HOME}/.config/SourceGit` or `${HOME}/.Sourcegit` |
|
||||
| macOS | `${HOME}/Library/Application Support/SourceGit` |
|
||||
|
||||
For **Windows** users:
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace SourceGit
|
|||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Native.OS.SetupDataDir();
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
|
||||
{
|
||||
LogException(e.ExceptionObject as Exception);
|
||||
|
|
|
@ -21,9 +21,9 @@ namespace SourceGit.Native
|
|||
void OpenWithDefaultEditor(string file);
|
||||
}
|
||||
|
||||
public static readonly string DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SourceGit");
|
||||
public static string DataDir { get; private set; } = string.Empty;
|
||||
public static string GitExecutable { get; set; } = string.Empty;
|
||||
public static List<Models.ExternalTool> ExternalTools { get; set; } = new List<Models.ExternalTool>();
|
||||
public static List<Models.ExternalTool> ExternalTools { get; set; } = [];
|
||||
|
||||
static OS()
|
||||
{
|
||||
|
@ -70,10 +70,19 @@ namespace SourceGit.Native
|
|||
|
||||
public static void SetupApp(AppBuilder builder)
|
||||
{
|
||||
_backend.SetupApp(builder);
|
||||
}
|
||||
|
||||
public static void SetupDataDir()
|
||||
{
|
||||
var osAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
if (string.IsNullOrEmpty(osAppDataDir))
|
||||
DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".SourceGit");
|
||||
else
|
||||
DataDir = Path.Combine(osAppDataDir, "SourceGit");
|
||||
|
||||
if (!Directory.Exists(DataDir))
|
||||
Directory.CreateDirectory(DataDir);
|
||||
|
||||
_backend.SetupApp(builder);
|
||||
}
|
||||
|
||||
public static void SetupEnternalTools()
|
||||
|
|
Loading…
Reference in a new issue