From 5c7d3bc967194099b635f753dc16c74b1c51f72b Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 4 Jul 2023 22:28:24 -0700 Subject: [PATCH] Fix "Value cannot be null. (Parameter 'path')" error when updating vlad sd.next --- .../Models/Packages/VladAutomatic.cs | 21 +++++++++++++++++++ .../ViewModels/PackageManagerViewModel.cs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/StabilityMatrix/Models/Packages/VladAutomatic.cs b/StabilityMatrix/Models/Packages/VladAutomatic.cs index a83dfb8e1..be837df4c 100644 --- a/StabilityMatrix/Models/Packages/VladAutomatic.cs +++ b/StabilityMatrix/Models/Packages/VladAutomatic.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; +using NLog; using StabilityMatrix.Helper; using StabilityMatrix.Helper.Cache; using StabilityMatrix.Models.Progress; @@ -136,4 +137,24 @@ void HandleExit(int i) VenvRunner?.RunDetached(args.TrimEnd(), HandleConsoleOutput, HandleExit, workingDirectory: installedPackagePath); } + + public override async Task Update(InstalledPackage installedPackage, IProgress? progress = null) + { + progress?.Report(new ProgressReport(0.1f, message: "Downloading package update...", isIndeterminate: true, type: ProgressType.Download)); + + var version = await GithubApi.GetAllCommits(Author, Name, installedPackage.InstalledBranch); + var latest = version is {Count: > 0} ? version[0] : null; + + if (latest == null) + { + Logger.Warn("No latest version found for vlad"); + return string.Empty; + } + + await PrerequisiteHelper.RunGit(workingDirectory: installedPackage.FullPath, "pull", "origin", installedPackage.InstalledBranch); + + progress?.Report(new ProgressReport(1f, message: "Update Complete", isIndeterminate: true, type: ProgressType.Generic)); + + return latest.Sha; + } } diff --git a/StabilityMatrix/ViewModels/PackageManagerViewModel.cs b/StabilityMatrix/ViewModels/PackageManagerViewModel.cs index fbe671277..4c0673a42 100644 --- a/StabilityMatrix/ViewModels/PackageManagerViewModel.cs +++ b/StabilityMatrix/ViewModels/PackageManagerViewModel.cs @@ -281,7 +281,7 @@ private async Task UpdateSelectedPackage() } ProgressText = $"Updating {SelectedPackage.DisplayName} to latest version..."; - package.InstallLocation = SelectedPackage.Path!; + package.InstallLocation = SelectedPackage.FullPath!; var progress = new Progress(progress => { var percent = Convert.ToInt32(progress.Percentage);