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. 123
      StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs
  2. 11
      StabilityMatrix.Core/Models/Packages/ComfyUI.cs
  3. 11
      StabilityMatrix.Core/Models/Packages/VladAutomatic.cs

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

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

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

@ -364,7 +364,16 @@ public class ComfyUI : BaseGitPackage
public override Task UpdateModelFolders( public override Task UpdateModelFolders(
DirectoryPath installDirectory, DirectoryPath installDirectory,
SharedFolderMethod sharedFolderMethod 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( public override Task RemoveModelFolderLinks(
DirectoryPath installDirectory, DirectoryPath installDirectory,

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

@ -433,7 +433,16 @@ public class VladAutomatic : BaseGitPackage
public override Task UpdateModelFolders( public override Task UpdateModelFolders(
DirectoryPath installDirectory, DirectoryPath installDirectory,
SharedFolderMethod sharedFolderMethod 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( public override Task RemoveModelFolderLinks(
DirectoryPath installDirectory, DirectoryPath installDirectory,

Loading…
Cancel
Save