-
-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix chocolatey not properly reporting available package versions
- Loading branch information
1 parent
74109e5
commit b2958a1
Showing
3 changed files
with
85 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateyDetailsProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using UniGetUI.Core.Data; | ||
using UniGetUI.Core.Logging; | ||
using UniGetUI.PackageEngine.Enums; | ||
using UniGetUI.PackageEngine.ManagerClasses.Manager; | ||
using UniGetUI.PackageEngine.Managers.PowerShellManager; | ||
using UniGetUI.PackageEngine.PackageClasses; | ||
|
||
namespace UniGetUI.PackageEngine.Managers.Chocolatey | ||
{ | ||
public class ChocolateyDetailsProvider : BaseNuGetDetailsProvider | ||
{ | ||
public ChocolateyDetailsProvider(BaseNuGet manager) : base(manager) | ||
{ } | ||
|
||
protected override async Task<string[]> GetPackageVersions_Unsafe(Package package) | ||
{ | ||
Process p = new() | ||
{ | ||
StartInfo = new ProcessStartInfo() | ||
{ | ||
// choco search php --exact --all-versions | ||
FileName = Manager.Status.ExecutablePath, | ||
Arguments = Manager.Properties.ExecutableCallArgs + $" search {package.Id} --exact --all-versions", | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
RedirectStandardInput = true, | ||
CreateNoWindow = true, | ||
StandardOutputEncoding = System.Text.Encoding.UTF8 | ||
} | ||
}; | ||
|
||
var logger = Manager.TaskLogger.CreateNew(LoggableTaskType.LoadPackageVersions, p); | ||
|
||
p.Start(); | ||
|
||
string? line; | ||
List<string> versions = new(); | ||
while ((line = await p.StandardOutput.ReadLineAsync()) != null) | ||
{ | ||
logger.AddToStdOut(line); | ||
if (line.Contains("[Approved]")) | ||
versions.Add(line.Split(' ')[1].Trim()); | ||
} | ||
logger.AddToStdErr(await p.StandardError.ReadToEndAsync()); | ||
await p.WaitForExitAsync(); | ||
logger.Close(p.ExitCode); | ||
|
||
return versions.ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters