Skip to content

Commit

Permalink
fix: mistakenly raise process error
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraZiling committed Jul 3, 2024
1 parent a97724f commit 56ef624
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/PipManager.Windows/Services/Environment/EnvironmentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ public bool TryKillProcess()
return false;
}
}

private static string ProcessErrorFilter(string error)
{
var errorBuilder = new StringBuilder();
foreach (var errorLine in error.Split('\n'))
{
if(!string.IsNullOrWhiteSpace(error) && !errorLine.Contains("[notice]"))
errorBuilder.Append(errorLine).Append('\n');
}
return errorBuilder.ToString().Trim();
}

private ActionResponse RaiseProcess(string arguments, DataReceivedEventHandler consoleOutputCallback,
string[]? extraParameters = null)
Expand All @@ -308,11 +319,12 @@ private ActionResponse RaiseProcess(string arguments, DataReceivedEventHandler c
BasicCommandProcess.OutputDataReceived += consoleOutputCallback;
BasicCommandProcess.Start();
BasicCommandProcess.BeginOutputReadLine();
var error = BasicCommandProcess.StandardError.ReadToEnd();
var error = ProcessErrorFilter(BasicCommandProcess.StandardError.ReadToEnd());
BasicCommandProcess.WaitForExit();
BasicCommandProcess.Close();
BasicCommandProcess.Dispose();
return new ActionResponse { Success = string.IsNullOrEmpty(error), Exception = ExceptionType.ProcessError, Message = error };
return new ActionResponse { Success = string.IsNullOrEmpty(error), Exception = ExceptionType.ProcessError, Message =
error };
}

#region Basic Command
Expand Down

0 comments on commit 56ef624

Please sign in to comment.