feat(backups): restore a whole snapshot (app + tablet) #57
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/28-snapshot-restore"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #28
Restore a whole backup snapshot at once, into the app or to the tablet. Only what's gone from the library comes back, always as new copies; nothing that's still there (unchanged, changed or in the trash) is touched.
Restore… on a snapshot's page → pick where → preview (how many come back, how many are left and why) → confirm. It runs in
RestoreSnapshotWorkeron the:backupsqueue, one run per user at a time, recorded inbackup_restore_runs; the page shows the latest run's progress.:folderrestore) and its items go in it under their own names. A folder that's in the trash now isn't made again: its items go to the nearest live folder, else My files. Gone items always get new ids (Jeremy's call).RestoreWriternever reads the backup. The writer goes in batches (restore_batch, default 50), one commit + sync per batch, folders first, at most 20 batches per sync, and reads each snapshot's manifest once per batch.Docs:
docs/backups.md("Restoring a whole snapshot").Tests:
test/rm_analyzer/backups/restore_snapshot_test.exs(standing, preview, app run, folder made again, live folder, batches of 1 → 3 commits, folder trashed now) and the snapshot LiveView.mix precommit: 919 pass.Not covered by the fake cloud: a real tablet. Worth one try on the tablet before shipping: delete a small folder, restore the snapshot to the reMarkable, and check the "(backup …)" folder shows up with its notebooks inside.
- A run :writing to the tablet whose account is gone has its unwritten restores failed ("your reMarkable was unpaired…"), so it finishes and later restores aren't refused (F2, Nye's probe). - RestoreWriter puts an item in a folder made in the same batch only if that folder built; else it goes to My files, named for the backup (F3). - The run and its Oban job go in one transaction, and a partial unique index lets a user have only one pending/running/writing run, so two tabs can't both start one. - The job catches exits as well as raises, so either fails the run. - Tests: manifest read once (app, and job + writer batch for the tablet), 412 mid-write retried once, exit fails the run, the index, plus Nye's probes and Armstrong's folder test.