Add export command and shared item tree

Introduces a pure, FUSE-independent item tree (buildItemTree) shared by the mount and export commands. The new export subcommand downloads Docspell search results into a local directory, mirroring the mount's friendly folder/year/month hierarchy without the by-id directory or metadata JSON file, for archival or migration.

- itemtree.go: pure item tree builder shared by mount and export
- mount.go: buildMountTree now converts the pure tree into FUSE nodes, with a shared fileNode per attachment across friendly and by-id paths
- export.go: export command with concurrent downloads, --dry-run, --skip-existing, --concurrency, --query, --limit, --auth-header
- main.go: wires up the export subcommand and its flags
- export_test.go: tests for plan collection, writes, skip-existing, failures, modtime
- README.md: documents the export command
This commit is contained in:
Jan Bader committed 2026-07-21 23:35:03 +02:00
1 parent c4a2e9d085
commit 5e88eaea97
6 files changed
+696 -98

No files matched your search

+20
View File
@@ -10,6 +10,7 @@ A small command-line helper for managing Docspell import folders, archiving file
- Preserve useful archive structure by Docspell folder and item date.
- Optionally upload files that do not yet exist in Docspell.
- Mount Docspell search results as a read-only filesystem.
- Export Docspell search results to a local directory for archival or migration.
- Resolve Docspell item URLs/IDs to local mounted paths, and local mounted paths back to Docspell item URLs.
## Requirements
@@ -86,6 +87,25 @@ DS_CC_UPLOAD_MISSING=true docspell-cli import
Uploaded files are not archived immediately. They are re-checked on the next run, after Docspell has processed and confirmed them.
## Export to a local directory
The `export` subcommand downloads Docspell search results into a local directory, reproducing the same folder/year/month hierarchy exposed by the `mount` command but without the `by-id/` directory or `.docspell-cli-metadata.json` file. This is useful for archival or migration to a plain on-disk layout.
The destination directory is a required positional argument; there is no config entry for it.
```bash
docspell-cli export ~/Documents/DocspellExport
```
Options:
- `--query`: Docspell item query to export. Defaults to `mountQuery` from the config.
- `--limit`: number of items fetched per API request. Defaults to `1000`.
- `--concurrency`: number of attachments to download in parallel. Defaults to `4`.
- `--dry-run`: print the files that would be written without downloading.
- `--skip-existing`: skip files that already exist in the destination.
- `--auth-header`: HTTP header used for the Docspell auth token. Defaults to `X-Docspell-Auth`.
## Read-only FUSE mount
The `mount` subcommand exposes Docspell search results as a read-only filesystem. It uses the same XDG config file and password command as the import/archive command.