Skip to content

feat(settings): datamap backup — export/import all datamaps#161

Merged
Nic-dorman merged 3 commits into
mainfrom
feat/datamap-backup-export
Jun 10, 2026
Merged

feat(settings): datamap backup — export/import all datamaps#161
Nic-dorman merged 3 commits into
mainfrom
feat/datamap-backup-export

Conversation

@Nic-dorman

Copy link
Copy Markdown
Contributor

Why

A datamap is the only local key to re-download a private upload — lose it (reinstall, reformat, new machine) and the data is orphaned on the network. Until now the only affordances were per-row Reveal / Copy-path; there was no first-class way to back up or restore datamaps. This was also a direct user request (closes #110).

What

A new Datamap backup card in Settings (main section, not Advanced) with:

  • Export — bundles every datamap into a single .zip (datamaps/*.datamap + manifest.json) at a location you choose.
  • Import — restores datamaps from such a zip, including on another machine.
  • The data-loss warning users asked for, plus a "store this securely" note (the backup grants access to your files).

How

New backend module src-tauri/src/datamap_backup.rs:

  • export_datamaps — driven off upload_history.json (authoritative), then sweeps both the fresh-install (~/Documents/Autonomi/Datamaps) and legacy config datamap dirs for orphan .datamap files so nothing is missed.
  • import_datamaps — validates the manifest format_version; extracts with a zip-slip guard (enclosed_name, basename-only); never clobbers a differing file (writes a -imported-N variant); dedupes by datamap address against existing history; and appends history rows so imports show up in the Files table.
  • The zip read/write core is factored into write_archive / import_archive taking explicit paths, so it is unit-testable without touching global dirs.

Frontend: the Settings card plus Export/Import handlers (@tauri-apps/plugin-dialog save/open; dialog:allow-save already granted), a datamap count, and a post-import history refresh. New en.json strings only — other locales fall back.

Adds the zip crate.

Tests

  • 6 new Rust unit tests (cargo test datamap_backup, all green): round-trip export→import, address dedupe, identical-file skip, no-clobber of a differing file, orphan counting, collision suffixing.
  • cargo check clean, nuxi typecheck clean, vitest 30/30.
  • Manually verified end-to-end in tauri dev: export → reimport reports all as already-present; files land in the datamap dir; rows appear in the Files table.

Notes

Per-row single export and a post-upload "save now" nudge were considered and dropped as redundant (Reveal + Copy-path + bulk export already cover the need) / unnecessary (datamaps persist automatically).

🤖 Generated with Claude Code

Nic-dorman and others added 3 commits June 10, 2026 14:58
Datamaps are the only local key to re-download a private upload, yet
there was no first-class way to back them up or restore them on another
machine (only per-row reveal/copy). Adds a "Datamap backup" card in
Settings with one-click Export (all datamaps + manifest → single zip)
and Import (restore from such a zip), plus the data-loss warning users
asked for.

Backend (new src-tauri/src/datamap_backup.rs):
- export_datamaps: drives off upload_history.json (authoritative), then
  sweeps the fresh-install + legacy datamap dirs for orphan .datamap
  files so nothing is missed; writes datamaps/* + manifest.json to a zip.
- import_datamaps: validates manifest format_version, extracts datamaps
  (zip-slip guarded via enclosed_name, basename-only), never clobbers a
  differing file, dedupes by address against existing history, and
  appends history rows so imports show in the Files table.

Frontend: Settings card (main section, not Advanced) with Export/Import
buttons, datamap count, and security note; refreshes history after
import. en.json strings only (other locales fall back).

Adds the `zip` crate. Absorbs the warning request from the closed
ant-ui#110.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Factor the zip read/write core into write_archive / import_archive that
take explicit paths (history + target dir injected), so the logic is
testable without touching global OS dirs. Adds 6 unit tests:
round-trip export→import, address dedupe, identical-file skip,
no-clobber of a differing file, orphan counting, and collision suffixing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Nic-dorman Nic-dorman merged commit e4a0389 into main Jun 10, 2026
4 checks passed
@Nic-dorman Nic-dorman deleted the feat/datamap-backup-export branch June 10, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning: Local Datamaps Required Information

1 participant