Browse Source

Let launch page setup model links

pull/165/head
Ionite 1 year ago
parent
commit
ccfa62ce32
No known key found for this signature in database
  1. 77
      StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs
  2. 11
      StabilityMatrix.Core/Models/Packages/ComfyUI.cs
  3. 11
      StabilityMatrix.Core/Models/Packages/VladAutomatic.cs

77
StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs

@ -111,26 +111,26 @@ public partial class PackageCardViewModel : ProgressViewModel
if (!settingsManager.IsLibraryDirSet)
return;
IsSharedModelSymlink = Package.PreferredSharedFolderMethod == SharedFolderMethod.Symlink;
IsSharedModelConfig =
Package.PreferredSharedFolderMethod == SharedFolderMethod.Configuration;
IsSharedModelDisabled = Package.PreferredSharedFolderMethod == SharedFolderMethod.None;
if (Package.PreferredSharedFolderMethod == null)
// Migrate old packages with no preferred shared folder method
if (Package.PreferredSharedFolderMethod is null)
{
var basePackage = packageFactory[Package.PackageName!];
switch (basePackage?.RecommendedSharedFolderMethod)
var basePackage = packageFactory[Package.PackageName!]!;
Package.PreferredSharedFolderMethod = basePackage.RecommendedSharedFolderMethod;
}
switch (Package.PreferredSharedFolderMethod)
{
case SharedFolderMethod.Symlink:
IsSharedModelSymlink = true;
break;
case SharedFolderMethod.Configuration:
IsSharedModelConfig = true;
break;
case SharedFolderMethod.Symlink:
IsSharedModelSymlink = true;
break;
case SharedFolderMethod.None:
IsSharedModelDisabled = true;
break;
}
default:
throw new ArgumentOutOfRangeException();
}
IsUpdateAvailable = await HasUpdate();
@ -368,32 +368,36 @@ public partial class PackageCardViewModel : ProgressViewModel
if (oldValue == newValue)
return;
var basePackage = packageFactory[Package!.PackageName];
if (newValue != Package!.PreferredSharedFolderMethod is SharedFolderMethod.Symlink)
{
if (!newValue)
{
var basePackage = packageFactory[Package!.PackageName!];
basePackage!.RemoveModelFolderLinks(Package.FullPath!, SharedFolderMethod.Symlink);
return;
}
basePackage!.SetupModelFolders(Package.FullPath!, SharedFolderMethod.Symlink);
settingsManager.Transaction(
s =>
s.InstalledPackages.First(x => x.Id == Package.Id).PreferredSharedFolderMethod =
SharedFolderMethod.Symlink
);
using var st = settingsManager.BeginTransaction();
Package.PreferredSharedFolderMethod = SharedFolderMethod.Symlink;
}
if (newValue)
{
IsSharedModelConfig = false;
IsSharedModelDisabled = false;
}
}
partial void OnIsSharedModelConfigChanged(bool oldValue, bool newValue)
{
if (oldValue == newValue)
return;
var basePackage = packageFactory[Package!.PackageName];
if (newValue != Package!.PreferredSharedFolderMethod is SharedFolderMethod.Configuration)
{
if (!newValue)
{
var basePackage = packageFactory[Package!.PackageName!];
basePackage!.RemoveModelFolderLinks(
Package.FullPath!,
SharedFolderMethod.Configuration
@ -401,32 +405,29 @@ public partial class PackageCardViewModel : ProgressViewModel
return;
}
basePackage!.SetupModelFolders(Package.FullPath!, SharedFolderMethod.Configuration);
settingsManager.Transaction(
s =>
s.InstalledPackages.First(x => x.Id == Package.Id).PreferredSharedFolderMethod =
SharedFolderMethod.Configuration
);
using var st = settingsManager.BeginTransaction();
Package.PreferredSharedFolderMethod = SharedFolderMethod.Configuration;
}
if (newValue)
{
IsSharedModelSymlink = false;
IsSharedModelDisabled = false;
}
}
partial void OnIsSharedModelDisabledChanged(bool oldValue, bool newValue)
partial void OnIsSharedModelDisabledChanged(bool value)
{
if (oldValue == newValue)
return;
if (!newValue)
return;
settingsManager.Transaction(
s =>
s.InstalledPackages.First(x => x.Id == Package!.Id).PreferredSharedFolderMethod =
SharedFolderMethod.None
);
if (value)
{
if (Package!.PreferredSharedFolderMethod is not SharedFolderMethod.None)
{
using var st = settingsManager.BeginTransaction();
Package.PreferredSharedFolderMethod = SharedFolderMethod.None;
}
IsSharedModelSymlink = false;
IsSharedModelConfig = false;
}
}
}

11
StabilityMatrix.Core/Models/Packages/ComfyUI.cs

@ -364,7 +364,16 @@ public class ComfyUI : BaseGitPackage
public override Task UpdateModelFolders(
DirectoryPath installDirectory,
SharedFolderMethod sharedFolderMethod
) => SetupModelFolders(installDirectory, sharedFolderMethod);
) =>
sharedFolderMethod switch
{
SharedFolderMethod.Symlink
=> base.UpdateModelFolders(installDirectory, sharedFolderMethod),
SharedFolderMethod.Configuration
=> SetupModelFolders(installDirectory, sharedFolderMethod),
SharedFolderMethod.None => Task.CompletedTask,
_ => Task.CompletedTask
};
public override Task RemoveModelFolderLinks(
DirectoryPath installDirectory,

11
StabilityMatrix.Core/Models/Packages/VladAutomatic.cs

@ -433,7 +433,16 @@ public class VladAutomatic : BaseGitPackage
public override Task UpdateModelFolders(
DirectoryPath installDirectory,
SharedFolderMethod sharedFolderMethod
) => SetupModelFolders(installDirectory, sharedFolderMethod);
) =>
sharedFolderMethod switch
{
SharedFolderMethod.Symlink
=> base.UpdateModelFolders(installDirectory, sharedFolderMethod),
SharedFolderMethod.None => Task.CompletedTask,
SharedFolderMethod.Configuration
=> SetupModelFolders(installDirectory, sharedFolderMethod),
_ => Task.CompletedTask
};
public override Task RemoveModelFolderLinks(
DirectoryPath installDirectory,

Loading…
Cancel
Save