Skip to content

Commit

Permalink
Merge pull request #147 from ionite34/fix-vlad-update
Browse files Browse the repository at this point in the history
Fix vlad update
  • Loading branch information
ionite34 authored Jul 5, 2023
2 parents 3dedd86 + c4898ef commit 68964d7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions StabilityMatrix/CheckpointManagerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<MenuItem Command="{Binding RenameCommand}" Header="Rename" />
<!-- ReSharper disable once Xaml.RedundantResource -->
<MenuItem Command="{Binding DeleteCommand}" Header="Delete" />
<!-- ReSharper disable once Xaml.RedundantResource -->
<MenuItem Header="Open on CivitAI"
Command="{Binding OpenOnCivitAiCommand}"
Visibility="{Binding IsConnectedModel, Converter={StaticResource BoolToVisibilityConverter}}"/>
</ContextMenu>
</ui:Card.ContextMenu>
<Grid>
Expand Down
6 changes: 6 additions & 0 deletions StabilityMatrix/Models/CheckpointFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ private async Task RenameAsync()
throw;
}
}

[RelayCommand]
private void OpenOnCivitAi()
{
ProcessRunner.OpenUrl($"https://civitai.com/models/{ConnectedModel.ModelId}");
}

// Loads image from path
private async Task LoadPreviewImage()
Expand Down
21 changes: 21 additions & 0 deletions StabilityMatrix/Models/Packages/VladAutomatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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;
Expand Down Expand Up @@ -217,4 +218,24 @@ void HandleExit(int i)

VenvRunner?.RunDetached(args.TrimEnd(), HandleConsoleOutput, HandleExit, workingDirectory: installedPackagePath);
}

public override async Task<string> Update(InstalledPackage installedPackage, IProgress<ProgressReport>? 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;
}
}
2 changes: 1 addition & 1 deletion StabilityMatrix/ViewModels/PackageManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProgressReport>(progress =>
{
var percent = Convert.ToInt32(progress.Percentage);
Expand Down

0 comments on commit 68964d7

Please sign in to comment.