Skip to content

Commit

Permalink
Handle winget "Unknown" version packages
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment committed Feb 25, 2024
1 parent 2c7eb4f commit 1cc3a85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/wingetui-interface/PackageEngine/Classes/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Package : INotifyPropertyChanged
public ManagerSource Source { get; set; }
public PackageManager Manager { get; }
public string UniqueId { get; }
public string NewVersion { get; }
public string NewVersion { get; set; }
public virtual bool IsUpgradable { get; } = false;
public PackageScope Scope { get; set; }
public string SourceAsString
Expand Down Expand Up @@ -238,7 +238,6 @@ protected void OnPropertyChanged([CallerMemberName] string name = null)
public class UpgradablePackage : Package
{
// Public properties
public new string NewVersion { get; }
public float NewVersionAsFloat { get; }
public override bool IsUpgradable { get; } = true;

Expand Down
4 changes: 2 additions & 2 deletions src/wingetui-interface/PackageEngine/Managers/Chocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@ protected override async Task<ManagerStatus> LoadManager()
};
process.Start();
status.Version = (await process.StandardOutput.ReadToEndAsync()).Trim();


// If the user is running bundled chocolatey and chocolatey is not in path, add chocolatey to path
if (/*Tools.GetSettings("ShownWelcomeWizard") && */!Tools.GetSettings("UseSystemChocolatey") && !Tools.GetSettings("ChocolateyAddedToPath") && !File.Exists(@"C:\ProgramData\Chocolatey\bin\choco.exe"))
{
// If the user is running bundled chocolatey and chocolatey is not in path, add chocolatey to path
AppTools.Log("Adding chocolatey to path");
string path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User);
Environment.SetEnvironmentVariable("PATH", $"{status.ExecutablePath.Replace("\\choco.exe", "\\bin")};{path}", EnvironmentVariableTarget.User);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ protected override async Task<AfterFinshAction> HandleSuccess()
{
AppTools.Log(ex);
}
await Task.Delay(0);

if(Package.Version == "Unknown")
await Package.AddToIgnoredUpdatesAsync(Package.NewVersion);

return AfterFinshAction.TimeoutClose;
}

Expand Down

0 comments on commit 1cc3a85

Please sign in to comment.