Skip to content

Commit 99d973f

Browse files
refactor: use Environment.ProcessPath instead of Process.GetCurrentProcess().MainModule!.FileName
Co-authored-by: heartacker <1876302+heartacker@users.noreply.github.com> Signed-off-by: leo <longshuang@msn.cn>
1 parent 837f40d commit 99d973f

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/Commands/Command.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
172172
}
173173

174174
// Force using this app as SSH askpass program
175-
var selfExecFile = Process.GetCurrentProcess().MainModule!.FileName;
175+
var selfExecFile = Environment.ProcessPath;
176176
start.Environment.Add("SSH_ASKPASS", selfExecFile); // Can not use parameter here, because it invoked by SSH with `exec`
177177
start.Environment.Add("SSH_ASKPASS_REQUIRE", "prefer");
178178
start.Environment.Add("SOURCEGIT_LAUNCH_AS_ASKPASS", "TRUE");

‎src/Native/Windows.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void ShowAllApplications()
7575

7676
public string GetDataDir()
7777
{
78-
var execFile = Process.GetCurrentProcess().MainModule!.FileName;
78+
var execFile = Environment.ProcessPath;
7979
var portableDir = Path.Combine(Path.GetDirectoryName(execFile)!, "data");
8080
if (Directory.Exists(portableDir))
8181
return portableDir;

‎src/Views/ConfirmRestart.axaml.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Diagnostics;
23

34
using Avalonia.Interactivity;
@@ -13,7 +14,7 @@ public ConfirmRestart()
1314

1415
private void Restart(object _1, RoutedEventArgs _2)
1516
{
16-
var selfExecFile = Process.GetCurrentProcess().MainModule!.FileName;
17+
var selfExecFile = Environment.ProcessPath;
1718
Process.Start(selfExecFile);
1819
App.Quit(-1);
1920
}

0 commit comments

Comments
 (0)