Back up save before overwrite

This commit is contained in:
2026-05-18 19:37:35 -07:00
parent 65599b9d2f
commit dfad8809c7
5 changed files with 89 additions and 1 deletions
+48
View File
@@ -0,0 +1,48 @@
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
EXPECTED = {
ROOT / "Source" / "AgrarianGame" / "AgrarianPersistenceSubsystem.h": [
"bool bBackupBeforeSave = true;",
"bool BackupExistingSave() const;",
],
ROOT / "Source" / "AgrarianGame" / "AgrarianPersistenceSubsystem.cpp": [
"if (SaveGame && bBackupBeforeSave)",
"BackupExistingSave();",
"FPaths::ProjectSavedDir()",
"TEXT(\"SaveGames\")",
"TEXT(\"Backups\")",
"FDateTime::UtcNow().ToString",
"IFileManager::Get().Copy",
],
ROOT / "Docs" / "PersistenceDesignDocument.md": [
"`UAgrarianPersistenceSubsystem::bBackupBeforeSave`",
"`Saved/SaveGames/Backups`",
"UTC timestamp",
],
ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
"[x] Add backup-before-save option.",
"`bBackupBeforeSave`",
"`Saved/SaveGames/Backups`",
],
}
def main() -> None:
missing = []
for path, snippets in EXPECTED.items():
text = path.read_text(encoding="utf-8")
for snippet in snippets:
if snippet not in text:
missing.append(f"{path.relative_to(ROOT)}: {snippet}")
if missing:
raise RuntimeError("Backup-before-save verification failed: " + "; ".join(missing))
print("PASS: backup-before-save is wired before slot overwrite.")
if __name__ == "__main__":
main()