Refuse newer save formats and add a gated dump of a live school.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 00:30:39 +03:00
co-authored by Cursor
parent 0ae633995f
commit a7955a0dce
13 changed files with 479 additions and 11 deletions
+22
View File
@@ -142,6 +142,21 @@ internal sealed class SchoolStore
continue;
}
if (save.Format > CurrentFormat)
{
_logger.LogWarning(
"Save {Path} is format {Format}; this build reads format {Current}. Leaving the file in place.",
path,
save.Format,
CurrentFormat);
continue;
}
if (save.Format < CurrentFormat)
{
save = UpgradeOlderSave(save);
}
// Claimed last, so a file rejected above does not reserve an id a good file needs.
if (!claimed.TryAdd(save.Id, path))
{
@@ -178,6 +193,13 @@ internal sealed class SchoolStore
return saves;
}
/// <summary>
/// Named upgrade seam for saves older than <see cref="CurrentFormat"/>. Empty on purpose:
/// missing fields already default and extra fields are ignored. Put a migration here when a
/// format bump actually needs one.
/// </summary>
internal static SchoolSave UpgradeOlderSave(SchoolSave save) => save;
public void Save(SchoolSave save)
{
WriteAtomic(SchoolPath(save.Id), save);