Skip to content

Commit d7bedd3

Browse files
committed
Avoid no-op of replacing ADB daemon when on path
1 parent 4b508b3 commit d7bedd3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

QuestPatcher.Core/AndroidDebugBridge.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ private async Task<bool> SetAdbPathIfValid(string adbExecutablePath)
139139
try
140140
{
141141
Log.Verbose("Checking if ADB at {AdbPath} is present and up-to-date", adbExecutablePath);
142-
string output = (await ProcessUtil.InvokeAndCaptureOutput(adbExecutablePath, "version")).AllOutput;
142+
var outputInfo = await ProcessUtil.InvokeAndCaptureOutput(adbExecutablePath, "version");
143+
string output = outputInfo.AllOutput;
144+
143145
Log.Debug("Output from checking ADB version: {VerisonOutput}", output);
144146

145147
int prefixPos = output.IndexOf(VersionPrefix);
@@ -168,7 +170,7 @@ private async Task<bool> SetAdbPathIfValid(string adbExecutablePath)
168170
{
169171
if (semver >= MinAdbVersion)
170172
{
171-
_adbPath = adbExecutablePath;
173+
_adbPath = outputInfo.FullPath ?? adbExecutablePath;
172174
return true;
173175
}
174176
}

QuestPatcher.Core/ProcessUtil.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public struct ProcessOutput
2828
/// The exit code of the process
2929
/// </summary>
3030
public int ExitCode { get; set; }
31+
32+
/// <summary>
33+
/// The full path to the executable that was invoked.
34+
/// Useful if running an executable on the PATH environnment variable.
35+
/// May be null if this information was unavailable.
36+
/// </summary>
37+
public string? FullPath { get; set; }
3138
}
3239

3340
public static class ProcessUtil
@@ -69,6 +76,7 @@ public static async Task<ProcessOutput> InvokeAndCaptureOutput(string fileName,
6976
};
7077

7178
process.Start();
79+
string? fullPath = process.MainModule?.FileName;
7280
process.BeginOutputReadLine();
7381
process.BeginErrorReadLine();
7482

@@ -78,7 +86,8 @@ public static async Task<ProcessOutput> InvokeAndCaptureOutput(string fileName,
7886
{
7987
StandardOutput = standardOutputBuilder.ToString(),
8088
ErrorOutput = errorOutputBuilder.ToString(),
81-
ExitCode = process.ExitCode
89+
ExitCode = process.ExitCode,
90+
FullPath = fullPath
8291
};
8392
}
8493
}

0 commit comments

Comments
 (0)