[PR #124] [MERGED] fix(backup): preserve snapshots created in the same second #142

Closed
opened 2026-10-15 20:53:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rehan-remade/universal-modder/pull/124
Author: @Milbaxter
Created: 10/6/2026
Status: ✅ Merged
Merged: 10/6/2026
Merged by: @rehan-remade

Base: main ← Head: fix/preserve-same-second-backups


📝 Commits (1)

  • c55e422 fix(backup): preserve snapshots created in the same second

📊 Changes

2 files changed (+113 additions, -6 deletions)

View changed files

📝 tests/test_um.py (+89 -0)
📝 um/backup.py (+24 -6)

📄 Description

What: Prevent save backups from silently overwriting each other when created within the same second.

create() currently uses a second-resolution filename and opens it in ZIP write mode. Creating another backup with the same name in that second replaces the first archive. Repeated restores can likewise overwrite the automatic pre-restore backups that are meant to make restores undoable.

Reserve filenames with exclusive creation, retrying collisions with numbered suffixes. The suffixes preserve existing filename sorting and skip gaps so default diff/restore still selects the newest snapshot. Failed or interrupted writes remove only the newly allocated archive.

Regression tests cover twelve distinct snapshots at a fixed timestamp, latest selection after deleted snapshots, concurrent creators, failed/interrupted writes, and preserving both undo snapshots across repeated restores. The original implementation failed the rapid-create, concurrent-create, and repeated-restore regressions.

Validation

  • Full suite: uv run --with pytest pytest -q tests — 72 passed, 1 skipped (Git Bash-only hook).
  • ./bin/um kb check --index — PASS: 59 notes checked.
  • ./bin/um publish check . — 0 failures; one existing absolute-user-path warning in the Project Zomboid field note.
  • All eleven CLI help commands and git diff --check passed.
  • Tested on macOS arm64, Python 3.13.16, with isolated FFmpeg/ffprobe 9.0.2 on PATH. Native Windows execution was not tested. Backup tests use temporary save fixtures.

Checklist

  • Code tests pass.
  • Knowledge index checked; regeneration not applicable (no field-note changes).
  • No game files, extracted assets, decompiled code dumps or secrets.
  • Nothing that cheats other players or bypasses anti-cheat / DRM / ownership checks.
  • Versions, verification and what was not verified are written down.
  • Authored by Codex (GPT-6) for @Milbaxter.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rehan-remade/universal-modder/pull/124 **Author:** [@Milbaxter](https://github.com/Milbaxter) **Created:** 10/6/2026 **Status:** ✅ Merged **Merged:** 10/6/2026 **Merged by:** [@rehan-remade](https://github.com/rehan-remade) **Base:** `main` ← **Head:** `fix/preserve-same-second-backups` --- ### 📝 Commits (1) - [`c55e422`](https://github.com/rehan-remade/universal-modder/commit/c55e422e76422c5afc2f0e33a234b97fccde8ecb) fix(backup): preserve snapshots created in the same second ### 📊 Changes **2 files changed** (+113 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_um.py` (+89 -0) 📝 `um/backup.py` (+24 -6) </details> ### 📄 Description **What:** Prevent save backups from silently overwriting each other when created within the same second. `create()` currently uses a second-resolution filename and opens it in ZIP write mode. Creating another backup with the same name in that second replaces the first archive. Repeated restores can likewise overwrite the automatic pre-restore backups that are meant to make restores undoable. Reserve filenames with exclusive creation, retrying collisions with numbered suffixes. The suffixes preserve existing filename sorting and skip gaps so default diff/restore still selects the newest snapshot. Failed or interrupted writes remove only the newly allocated archive. Regression tests cover twelve distinct snapshots at a fixed timestamp, latest selection after deleted snapshots, concurrent creators, failed/interrupted writes, and preserving both undo snapshots across repeated restores. The original implementation failed the rapid-create, concurrent-create, and repeated-restore regressions. **Validation** - Full suite: `uv run --with pytest pytest -q tests` — **72 passed, 1 skipped** (Git Bash-only hook). - `./bin/um kb check --index` — **PASS: 59 notes checked**. - `./bin/um publish check .` — **0 failures**; one existing absolute-user-path warning in the Project Zomboid field note. - All eleven CLI help commands and `git diff --check` passed. - Tested on macOS arm64, Python 3.13.16, with isolated FFmpeg/ffprobe 9.0.2 on PATH. Native Windows execution was not tested. Backup tests use temporary save fixtures. **Checklist** - [x] Code tests pass. - [x] Knowledge index checked; regeneration not applicable (no field-note changes). - [x] No game files, extracted assets, decompiled code dumps or secrets. - [x] Nothing that cheats other players or bypasses anti-cheat / DRM / ownership checks. - [x] Versions, verification and what was not verified are written down. - [x] Authored by Codex (GPT-6) for @Milbaxter. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 20:53:46 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rehan-remade/universal-modder#142
No description provided.