Skip to content

fix(librtbit): track the new location after moving to the completed folder - #322

Open
jdrouet wants to merge 2 commits into
TheDancingDeveloper-org:mainfrom
jdrouet:fix/321-completed-folder-path
Open

jdrouet wants to merge 2 commits into
TheDancingDeveloper-org:mainfrom
jdrouet:fix/321-completed-folder-path

Conversation

@jdrouet

@jdrouet jdrouet commented Nov 29, 2026

Copy link
Copy Markdown

Fixes #321.

Problem

When RTBIT_COMPLETED_FOLDER is set, a finished torrent is moved to the completed folder, but the torrent keeps its old location. The WebUI API v2 compat layer then reports the old save_path and content_path, so Sonarr, Radarr and Lidarr imports fail.

Changes

  • Session::move_completed_torrent sets the torrent's location to the completed folder and persists it, so a restart keeps it.
  • New ManagedTorrentHandle::output_folder_root keeps the save root when the new location still ends with the add-time subfolder. Without it, a multi-file torrent would report content_path as complete/Album/Album. qbit_save_path and the persistence code both use it. Output is unchanged for torrents that haven't moved.
  • The move skips torrents already in the completed folder. A restored torrent runs the completion code again, and without the skip a multi-file torrent would be flattened into the completed folder root on each restart. A download folder nested inside the completed folder still moves.

Known limitation

The live storage keeps its old root until the next restart. Until then, deleting the torrent with its files, or moving it with set_location, still targets the old folder. Before this change these actions were broken even after a restart. Fixing it needs a new storage method, so it is left for a follow-up.

Validation

  • New test completed_folder_move_updates_reported_paths adds a multi-file torrent with a save root, waits for the move, and checks save_path, content_path and the persisted location.
  • cargo test -p swarmforge --features http-api --lib: 404 passed, 1 failed. The failure was tests::e2e::test_e2e_download_utp, a timeout waiting for background tasks. It passed when the e2e tests were re-run alone, and those tests don't set a completed folder.
  • cargo clippy --all-targets -- -D warnings and cargo fmt --check are clean.

Keeps the save root when a torrent moves to a folder that still ends with
its add-time subfolder, so multi-file torrents keep a correct content_path.
…older

The completed-folder move left the torrent pointing at the download folder,
so the WebUI API v2 reported the old save_path and content_path and *arr
imports failed. Set and persist the new location, and skip torrents already
in the completed folder after a restart.

Fixes TheDancingDeveloper-org#321
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.

qBittorrent API reports the pre-move path after a torrent is moved to the completed folder

1 participant