This repository has been archived on 2026-05-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AgrarianGameArchive/Scripts/verify_backup_before_save.py
2026-05-18 19:37:35 -07:00

49 lines
1.4 KiB
Python

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()