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