Skip to content

Commit dc649e6

Browse files
committed
refactor: rewrite the portable mode (#851)
1 parent 093176d commit dc649e6

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationD
6464
| macOS | `${HOME}/Library/Application Support/SourceGit` |
6565

6666
> [!TIP]
67-
> You can open this data storage directory from the main menu.
67+
> * You can open this data storage directory from the main menu `Open Data Storage Directory`.
68+
> * You can create a `data` folder next to the `SourceGit` executable to force this app to store data (user settings, downloaded avatars and crash logs) into it (Portable-Mode). Only works on Windows.
6869
6970
For **Windows** users:
7071

@@ -81,7 +82,6 @@ For **Windows** users:
8182
scoop install sourcegit
8283
```
8384
* Pre-built binaries can be found in [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest)
84-
* You can run `dotnet publish -c Release -r win-x64 -p:EnablePortable=true -o $YOUR_PUBLISH_DIR .\src\SourceGit.csproj` to build a portable version.
8585

8686
For **macOS** users:
8787

src/Native/OS.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
#if ENABLE_PORTABLE
43
using System.Diagnostics;
5-
#endif
64
using System.IO;
75

86
using Avalonia;
@@ -58,16 +56,17 @@ public static void SetupApp(AppBuilder builder)
5856

5957
public static void SetupDataDir()
6058
{
61-
#if ENABLE_PORTABLE
6259
if (OperatingSystem.IsWindows())
6360
{
6461
var execFile = Process.GetCurrentProcess().MainModule!.FileName;
65-
DataDir = Path.Combine(Path.GetDirectoryName(execFile), "data");
66-
if (!Directory.Exists(DataDir))
67-
Directory.CreateDirectory(DataDir);
68-
return;
62+
var portableDir = Path.Combine(Path.GetDirectoryName(execFile), "data");
63+
if (Directory.Exists(portableDir))
64+
{
65+
DataDir = portableDir;
66+
return;
67+
}
6968
}
70-
#endif
69+
7170
var osAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
7271
if (string.IsNullOrEmpty(osAppDataDir))
7372
DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".sourcegit");

src/SourceGit.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<DefineConstants>$(DefineConstants);DISABLE_UPDATE_DETECTION</DefineConstants>
3131
</PropertyGroup>
3232

33-
<PropertyGroup Condition="'$(EnablePortable)' == 'true'">
34-
<DefineConstants>$(DefineConstants);ENABLE_PORTABLE</DefineConstants>
35-
</PropertyGroup>
36-
3733
<ItemGroup>
3834
<AvaloniaResource Include="App.ico" />
3935
<AvaloniaResource Include="Resources/Fonts/*" />

0 commit comments

Comments
 (0)