trackslash
VAULT-62 P2

Only count a PDF backup as saved when it really was, and don't leave backup PDFs behind

0
All issues

Description

Found while testing VAULT-15 in the simulator.

A PDF backup counts as the Last Backup once the share sheet reports that it finished (VAULT-3, #604). Two activities get that wrong:

  • Copy counts as a backup. Copy reports "completed", so the app shows "Backup Saved" and Last Backup turns green, but nothing was saved anywhere.
    • Copy also puts the whole encrypted backup on the pasteboard. With Universal Clipboard, that can reach other devices (MANIFESTO.md C7).
  • Saving through Markup isn't recorded. Markup β†’ X β†’ "Save File To…" β†’ Save does put an identical backup in Files. But the share sheet reports "not completed" with no activity type, so the screen stays on "Save Your Backup" and Done warns "Your Backup Isn't Saved".

Fix:

  • Exclude .copyToPasteboard and .markupAsPDF from the backup PDF's share sheet.
  • A "Copy" inside the print options still reports a completed print. It can't be told apart from a real print, so it's accepted as a residual. Say so in the PR.

Also, from the same testing:

  • Old backup PDFs pile up in the app's tmp/.
    • Each one is an encrypted copy of the whole vault as it was, including items since deleted by killphrase (C6).
    • Delete the PDF as soon as the share sheet finishes, whether or not it completed, and clear any leftovers the next time the backup page opens.
  • Swapped dates. BackupEventLoggerImpl seems to store the save time as backupDate and the PDF's creation time as eventDate, the reverse of what VaultBackupEvent's comments say. Check it, and fix whichever is wrong.

Tests:

  • Unit tests that the share sheet for the backup excludes those activities.
  • Unit tests that the temporary PDF is removed after completion and after cancellation.
  • Unit tests for the event's dates.

Sub-issues

0

Linked issues

0

GitHub

0

No branches or pull requests linked.

Comments

1
Bradley

Fixed in https://github.com/badbundle/vault-app/pull/638 (merged as 3b15f4ff).

Share sheet:

  • The backup's share sheet no longer offers Copy or Markup. It still offers Save to Files, Print, AirDrop and apps.
  • Residual: a Copy inside Print's own options still reports a completed print. UIKit gives no way to tell it from a real print, so it's accepted.

No more backup PDFs in tmp/:

  • The PDF stays in memory until Save or Print. It's written to a file only then, and deleted as soon as the share sheet closes, whether or not it was saved.
  • The Backups page deletes any leftover vault-export-*.pdf files when it opens.
  • If the file can't be written, the page says so in red.

Dates: the docs were right and BackupEventLoggerImpl was wrong. backupDate is now when the backup was made, and eventDate is when it was saved. The logger's date: labels were renamed to backupDate: so the mix-up can't come back. Stored events keep their swapped dates until the next backup; the two are normally minutes apart.

Tests:

  • The share-sheet exclusions.
  • The temporary file being written only on share and deleted after both a completed and a cancelled share.
  • Leftover cleanup.
  • Event dates, with a staleness check that fails if they're swapped.
  • A snapshot of the write-failure state.

Checked in the simulator:

  • Save to Files still records the backup.
  • tmp/ is empty afterwards.
  • A leftover PDF is swept when Backups opens.