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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user