mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
refactor: rewrite the portable mode (#851)
This commit is contained in:
parent
093176d10b
commit
dc649e6142
3 changed files with 9 additions and 14 deletions
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if ENABLE_PORTABLE
|
||||
using System.Diagnostics;
|
||||
#endif
|
||||
using System.IO;
|
||||
|
||||
using Avalonia;
|
||||
|
@ -58,16 +56,17 @@ namespace SourceGit.Native
|
|||
|
||||
public static void SetupDataDir()
|
||||
{
|
||||
#if ENABLE_PORTABLE
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
var execFile = Process.GetCurrentProcess().MainModule!.FileName;
|
||||
DataDir = Path.Combine(Path.GetDirectoryName(execFile), "data");
|
||||
if (!Directory.Exists(DataDir))
|
||||
Directory.CreateDirectory(DataDir);
|
||||
return;
|
||||
var portableDir = Path.Combine(Path.GetDirectoryName(execFile), "data");
|
||||
if (Directory.Exists(portableDir))
|
||||
{
|
||||
DataDir = portableDir;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
var osAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
if (string.IsNullOrEmpty(osAppDataDir))
|
||||
DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".sourcegit");
|
||||
|
|
|
@ -30,10 +30,6 @@
|
|||
<DefineConstants>$(DefineConstants);DISABLE_UPDATE_DETECTION</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(EnablePortable)' == 'true'">
|
||||
<DefineConstants>$(DefineConstants);ENABLE_PORTABLE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="App.ico" />
|
||||
<AvaloniaResource Include="Resources/Fonts/*" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue