feat(settings): datamap backup — export/import all datamaps#161
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
.zip(datamaps/*.datamap+manifest.json) at a location you choose.How
New backend module
src-tauri/src/datamap_backup.rs:export_datamaps— driven offupload_history.json(authoritative), then sweeps both the fresh-install (~/Documents/Autonomi/Datamaps) and legacy config datamap dirs for orphan.datamapfiles so nothing is missed.import_datamaps— validates the manifestformat_version; extracts with a zip-slip guard (enclosed_name, basename-only); never clobbers a differing file (writes a-imported-Nvariant); dedupes by datamap address against existing history; and appends history rows so imports show up in the Files table.write_archive/import_archivetaking explicit paths, so it is unit-testable without touching global dirs.Frontend: the Settings card plus Export/Import handlers (
@tauri-apps/plugin-dialogsave/open;dialog:allow-savealready granted), a datamap count, and a post-import history refresh. Newen.jsonstrings only — other locales fall back.Adds the
zipcrate.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 checkclean,nuxi typecheckclean,vitest30/30.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