Shows can be expanded to list their seasons, each with its size and its own Dry run / Move buttons. A season joins the same show on the other server, so finished seasons can go to the big server while the current one stays on the fast one. - Source exports a season from the show folder, with a manifest of just that season's folder plus the show's loose non-video files. Refuses seasons with no folder of their own, or whose folder holds otherseasons' episodes. - Destination finds the show by provider ID, then name. If it already has the show, the show's own files are skipped (Job.skip_files) and never overwritten; otherwise they come with the season. Refuses if the season folder already exists. - Only episode watch state is carried for a season. - Source trashes just the season folder; after the last season, the leftover show folder joins it in the same trash entry if no videos remain. The chosen trash entry is saved so a re-run after a crash finishes in the same place. - New GET /seasons (UI and peer). Fake Jellyfin gains season items. - e2e tests: season into a new show, into an existing show, last season leaving, destination already has the season, misfiled episodes.
4.8 KiB
CLAUDE.md
Guidance for Claude Code (and humans) working in this repo.
What this is
jellymove moves movies and TV series between two separate Jellyfin servers (e.g. a fast-but-small cloud box and a slow-but-big home NAS, federated by Jellyswarrm). One agent runs next to each Jellyfin. The destination pulls from the source over HTTP range requests, verifies with BLAKE3, renames into its library, waits for Jellyfin to index it, re-applies every user's watch state, then tells the source to move its copy to a hidden trash folder.
Design background and prior-art research: docs/ARCHITECTURE.md.
Commands
cargo test --workspace # all tests (~15 s; e2e spins up 2 agents + 2 fake Jellyfins)
cargo clippy --workspace --all-targets # must be warning-free
npm --prefix ui ci && npm --prefix ui run build # UI → ui/dist (embedded by rust-embed)
npm --prefix ui run check # svelte-check
cargo run -p jm-server --example demo # two agents on :8097 (cloud) and :8098 (home) with fake media
npm --prefix ui run dev # Vite dev server proxying /api to 127.0.0.1:8097
cargo run -p jellymove -- --config jellymove.toml # real daemon
Build the UI before cargo build --release, or the binary serves a "UI not
built" page. Debug builds read ui/dist from disk, so rebuilding the UI is
enough while developing.
Layout
| Crate | Role |
|---|---|
jm-core |
Pure domain: Job/Stage/JobStatus, ExportInfo/Manifest, PathMap, folder safety rules, user-data types. No I/O. |
jm-transfer |
Manifest building + BLAKE3, range_response (serve), Puller (resume/retry/throttle/verify), promote (atomic rename). |
jm-jellyfin |
Thin typed client for the ~10 Jellyfin endpoints used. |
jm-store |
SQLite (rusqlite, WAL). Jobs, exports and cached folder sizes as JSON blobs. Migrations are the MIGRATIONS array; append only. |
jm-server |
axum app: /api/* (UI), /peer/v1/* (agent↔agent), export.rs (source side), runner.rs (destination side), embedded UI. |
jellymove |
Binary: clap + figment config loading, tracing setup. |
ui/ |
Svelte 5 (runes) + Vite + TS SPA. No SvelteKit. |
Invariants — don't break these
- Nothing is deleted from the source until the destination has indexed every
file (
Stage::TargetScanned) and user data is applied. Source "deletion" is a rename into<library>/.jellymove-trash/<entry>/, neverremove_dir_all. The only code that deletes istrash::empty, which resolves opaque entry IDs by scanning the trash folders and only removes real folders directly inside them. - Every runner step is idempotent.
Job.stageis the last completed milestone; the runner re-executes from there after a crash. If you add a stage, make re-running it safe. - Peers can only read exported files by index (
/exports/{id}/files/{idx}), never by path. Relative paths from a peer always go throughjm_core::paths::join_relative, which rejects.., absolute paths and\. - Never overwrite at the destination:
planrefuses if the target folder exists (for a season, the season's folder inside the show);promoterefuses on any clash before renaming anything. A season going into a show the destination already has skips the show's own files (Job.skip_files). - Partial/trash folders start with
.jellymove-(Jellyfin skips dot-folders) and get a.ignorefile. - Two path namespaces: what Jellyfin reports vs. what the agent sees.
Convert with
cfg.path_map.to_local()/to_jellyfin(); Jellyfin API calls always take Jellyfin-namespace paths.
Jellyfin facts that shape the design
- Item IDs derive from file paths, so a moved item is a new item with no watch history; hence user-data capture on the source and re-apply on the destination. We find the new item by path (we know exactly where we put it), then episodes by (season, episode).
POST /Library/Media/Updatedreturns 204 even for paths outside every library and only scans afterLibraryMonitorDelay(60 s default). Always poll.- User-data routes are the 10.9+ ones (
/UserItems/{id}/UserData). Verify against a real server's/api-docs/openapi.jsonbefore trusting.
Testing approach
crates/jm-server/tests/fake_jellyfin/ is a filesystem-backed fake Jellyfin
(path-derived IDs, delayed scans, user data). E2E tests in
crates/jm-server/tests/e2e.rs run two real agents against two fakes. Add an
e2e test for any behaviour change in the move flow. The fake is not proof
of real-Jellyfin compatibility; see "Not yet verified" in README.
Style
- Errors:
thiserrorin library crates,anyhowwith.context()injm-server. Job failure messages are shown to users; make them actionable. - UI copy: plain, short, UK English. Svelte 5 runes only; run the Svelte
autofixer /
npm run checkafter editing components.