Skip to content

Commit c6a4af1

Browse files
authored
Merge pull request #439 from LykosAI/main
Error handling for index checkpoints
2 parents 909a290 + edb81c1 commit c6a4af1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
1515
- Improved error messages with process output for 7z extraction errors
1616
- Fixed missing tkinter dependency for OneTrainer on Windows
1717
- Fixed auto-update on macOS not starting new version from an issue in starting .app bundles with arguments
18+
- Fixed [#436](https://github.com/LykosAI/StabilityMatrix/issues/436) - Crash on invalid json files during checkpoint indexing
1819

1920
## v2.8.0
2021
### Added

StabilityMatrix.Core/Services/SettingsManager.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,22 @@ public void IndexCheckpoints()
425425
foreach (var jsonFile in connectedModelJsons)
426426
{
427427
var json = File.ReadAllText(jsonFile);
428-
var connectedModel = JsonSerializer.Deserialize<ConnectedModelInfo>(json);
429428

430-
if (connectedModel?.Hashes.BLAKE3 != null)
429+
if (string.IsNullOrWhiteSpace(json))
430+
continue;
431+
432+
try
433+
{
434+
var connectedModel = JsonSerializer.Deserialize<ConnectedModelInfo>(json);
435+
436+
if (connectedModel?.Hashes.BLAKE3 != null)
437+
{
438+
modelHashes.Add(connectedModel.Hashes.BLAKE3);
439+
}
440+
}
441+
catch (Exception e)
431442
{
432-
modelHashes.Add(connectedModel.Hashes.BLAKE3);
443+
Logger.Warn(e, "Failed to parse connected model info from {JsonFile}", jsonFile);
433444
}
434445
}
435446

0 commit comments

Comments
 (0)