import files: read an account export back, manifest and all #54

Merged
jcoffey-dev merged 1 commits from feat/import-files into main 2026-10-31 20:52:56 +00:00
1 Commits
Author SHA1 Message Date
jcoffey-dev bb9bc66d63 import files: read an account export back, manifest and all
ci / test (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 4m31s
ci / announce (pull_request) Skipped
export-files writes the layout specified at
https://coffeylabs.org/specs/account-export/, and until now only its open
formats could be read back (import maildir, import takeout). The parts only
the manifest holds were lost on the way back in: real folder names, roles
and subscriptions, the default address book and calendar, calendar colors
and time zones, the active Sieve script, media types, links, identities and
their signatures.

import files reads all of it. Copies of a message kept in several folders
come back as one message in each, matched by content, since the spec says
nothing in a file name but the Maildir flags can be relied on. Every path
in the manifest is checked to stay inside its part of the export and no
symbolic link is followed. A tree without a manifest, or of a later layout
version, is refused; the rc.2 format name is accepted. A second run brings
the archive up to date and deletes nothing.

Archives gain the source kind `files` (the sources table is rebuilt with
foreign keys off, so nothing cascades) and a sync_id_files table.

An archive exported, imported and exported again gives the same tree.
2026-10-31 13:41:06 -07:00