Enhance school management and protocol handling by introducing a new worker failure mechanism, ensuring proper cleanup of schools when a worker thread encounters an error. Update the map snapshot protocol to allow larger school data sizes, improving the handling of extensive map layouts. Revise documentation to reflect changes in save intervals and introduce a minimum save interval for better performance. Update tests to validate the new functionalities and ensure robustness in handling large data scenarios.
ci / server (push) Failing after 3m29s
ci / client (push) Successful in 16s

This commit is contained in:
Leonid Pershin
2026-08-18 17:02:28 +03:00
parent 6ca9ff9d03
commit f000b128f6
14 changed files with 325 additions and 74 deletions
+25
View File
@@ -92,6 +92,11 @@ internal sealed class SchoolStore
{
var saves = new List<SchoolSave>();
// The id inside the file decides which school this is and which file it is saved back to,
// so two files claiming the same id would give the menu two cards over one worker and then
// overwrite each other on the next save.
var claimed = new Dictionary<int, string>();
foreach (var path in Directory.EnumerateFiles(DirectoryPath, "*.json"))
{
if (string.Equals(Path.GetFileName(path), IndexFileName, StringComparison.OrdinalIgnoreCase))
@@ -109,6 +114,15 @@ internal sealed class SchoolStore
continue;
}
if (save.Id <= 0)
{
_logger.LogWarning(
"Save {Path} has id {Id}; ids start at 1. Leaving the file in place.",
path,
save.Id);
continue;
}
if (!GameClock.IsValidStartDate(save.GameTime))
{
_logger.LogWarning(
@@ -117,6 +131,17 @@ internal sealed class SchoolStore
continue;
}
// Claimed last, so a file rejected above does not reserve an id a good file needs.
if (!claimed.TryAdd(save.Id, path))
{
_logger.LogWarning(
"Save {Path} claims id {Id}, already taken by {Owner}; leaving the file in place.",
path,
save.Id,
claimed[save.Id]);
continue;
}
saves.Add(new SchoolSave
{
Format = save.Format,