Browse Source

Fix invoke update & settings not saving when 0 bytes

pull/365/head
JT 11 months ago
parent
commit
8f8f85cf4a
  1. 2
      CHANGELOG.md
  2. 4
      StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs
  3. 31
      StabilityMatrix.Core/Services/SettingsManager.cs

2
CHANGELOG.md

@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
### Fixed
- Fixed Python Packages dialog crash due to pip commands including warnings
- Fixed Base Model downloads from the Hugging Face tab downloading to the wrong folder
- Fixed InvokeAI `! [rejected] v3.4.0post2 -> v3.4.0post2 (would clobber existing tag)` error on updating to the latest version
- Fixed settings not saving in some scenarios, such as when the `settings.json` file existed but was empty
## v2.7.5
### Fixed

4
StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs

@ -319,7 +319,7 @@ public abstract class BaseGitPackage : BasePackage
{
progress?.Report(new ProgressReport(-1f, "Fetching tags...", isIndeterminate: true));
await PrerequisiteHelper
.RunGit(new[] { "fetch", "--tags" }, onConsoleOutput, installedPackage.FullPath)
.RunGit(new[] { "fetch", "--tags", "--force" }, onConsoleOutput, installedPackage.FullPath)
.ConfigureAwait(false);
progress?.Report(
@ -353,7 +353,7 @@ public abstract class BaseGitPackage : BasePackage
// fetch
progress?.Report(new ProgressReport(-1f, "Fetching data...", isIndeterminate: true));
await PrerequisiteHelper
.RunGit("fetch", onConsoleOutput, installedPackage.FullPath)
.RunGit(new[] { "fetch", "--force" }, onConsoleOutput, installedPackage.FullPath)
.ConfigureAwait(false);
if (versionOptions.IsLatest)

31
StabilityMatrix.Core/Services/SettingsManager.cs

@ -134,7 +134,9 @@ public class SettingsManager : ISettingsManager
{
if (expression.Body is not MemberExpression memberExpression)
{
throw new ArgumentException($"Expression must be a member expression, not {expression.Body.NodeType}");
throw new ArgumentException(
$"Expression must be a member expression, not {expression.Body.NodeType}"
);
}
var propertyInfo = memberExpression.Member as PropertyInfo;
@ -226,7 +228,10 @@ public class SettingsManager : ISettingsManager
}
// Invoke property changed event, passing along sender
SettingsPropertyChanged?.Invoke(sender, new RelayPropertyChangedEventArgs(targetPropertyName, true));
SettingsPropertyChanged?.Invoke(
sender,
new RelayPropertyChangedEventArgs(targetPropertyName, true)
);
};
// Set initial value if requested
@ -331,7 +336,10 @@ public class SettingsManager : ISettingsManager
var libraryJsonFile = Compat.AppDataHome.JoinFile("library.json");
var library = new LibrarySettings { LibraryPath = path };
var libraryJson = JsonSerializer.Serialize(library, new JsonSerializerOptions { WriteIndented = true });
var libraryJson = JsonSerializer.Serialize(
library,
new JsonSerializerOptions { WriteIndented = true }
);
libraryJsonFile.WriteAllText(libraryJson);
// actually create the LibraryPath directory
@ -481,7 +489,9 @@ public class SettingsManager : ISettingsManager
public string? GetActivePackageHost()
{
var package = Settings.InstalledPackages.FirstOrDefault(x => x.Id == Settings.ActiveInstalledPackageId);
var package = Settings.InstalledPackages.FirstOrDefault(
x => x.Id == Settings.ActiveInstalledPackageId
);
if (package == null)
return null;
var hostOption = package.LaunchArgs?.FirstOrDefault(x => x.Name.ToLowerInvariant() == "host");
@ -494,7 +504,9 @@ public class SettingsManager : ISettingsManager
public string? GetActivePackagePort()
{
var package = Settings.InstalledPackages.FirstOrDefault(x => x.Id == Settings.ActiveInstalledPackageId);
var package = Settings.InstalledPackages.FirstOrDefault(
x => x.Id == Settings.ActiveInstalledPackageId
);
if (package == null)
return null;
var portOption = package.LaunchArgs?.FirstOrDefault(x => x.Name.ToLowerInvariant() == "port");
@ -615,11 +627,13 @@ public class SettingsManager : ISettingsManager
if (fileStream.Length == 0)
{
Logger.Warn("Settings file is empty, using default settings");
isLoaded = true;
return;
}
if (
JsonSerializer.Deserialize(fileStream, SettingsSerializerContext.Default.Settings) is { } loadedSettings
JsonSerializer.Deserialize(fileStream, SettingsSerializerContext.Default.Settings) is
{ } loadedSettings
)
{
Settings = loadedSettings;
@ -656,7 +670,10 @@ public class SettingsManager : ISettingsManager
return;
}
var jsonBytes = JsonSerializer.SerializeToUtf8Bytes(Settings, SettingsSerializerContext.Default.Settings);
var jsonBytes = JsonSerializer.SerializeToUtf8Bytes(
Settings,
SettingsSerializerContext.Default.Settings
);
File.WriteAllBytes(SettingsPath, jsonBytes);
}

Loading…
Cancel
Save