Add qbt-relink.sh to fix qBittorrent after a Sonarr import
Sonarr's hardlink-import removes files from their original torrent-named folder, but qBittorrent's own records still point there - the next recheck or peer request flips those downloads to "missing files". qbt-relink.sh re-points a torrent's location and per-file names at the Sonarr-organized destination and triggers a recheck, so seeding continues against the same underlying data (same inode) instead of erroring out or needing a re-download. Documented as a required step in the sonarr skill's per-show migration workflow. Claude-Session: https://claude.ai/code/session_01HZQK6jHmdTpFjFZM8FUnqA
This commit is contained in:
@@ -37,7 +37,53 @@ once.
|
||||
5. **Clean up the empty source folder**:
|
||||
`docker exec jellyfin rmdir "<raw folder path>"` (any container with the
|
||||
`nas_media` mount works).
|
||||
6. **Verify Plex picks it up correctly** — this is not automatic, see below.
|
||||
6. **Re-point qBittorrent at the new location** — not automatic, see below.
|
||||
Skip only if the show was never actually downloaded via qBittorrent (rare).
|
||||
7. **Verify Plex picks it up correctly** — also not automatic, see below.
|
||||
|
||||
## Re-pointing qBittorrent after an import
|
||||
|
||||
Sonarr's hardlink-import removes the file from its original torrent-named
|
||||
folder (only the new hardlinked copy remains) — qBittorrent's own record of
|
||||
that download doesn't know this happened and silently keeps pointing at the
|
||||
now-empty original path. It won't show an error immediately (a `stalledUP`
|
||||
torrent doesn't re-read its files until asked to), but the next recheck or
|
||||
peer request will flip it to a `missingFiles` error state.
|
||||
|
||||
Fix it with `./qbt-relink.sh <torrent-hash> <new-season-folder>` (repo root):
|
||||
|
||||
```bash
|
||||
./qbt-relink.sh 8601b9b9a7164ff5038aa1f8e678e3e708eea845 "/data/video/tv/Andor (2022)/Season 02"
|
||||
```
|
||||
|
||||
Find the hash first:
|
||||
```bash
|
||||
source ~/.claude-homelab/.env
|
||||
bash ~/.claude/plugins/cache/claude-homelab/homelab-core/*/skills/qbittorrent/scripts/qbit-api.sh list \
|
||||
| python3 -c "import sys,json; [print(t['hash'], t['name']) for t in json.load(sys.stdin)]" | grep -i "<show name>"
|
||||
```
|
||||
|
||||
It sets the torrent's location to the season folder, renames each file to
|
||||
match Sonarr's output (paired by sorted order — always check the printed
|
||||
preview makes sense), then triggers a recheck. Since it's the same underlying
|
||||
data (hardlink, same inode), the hash check passes and the torrent goes back
|
||||
to seeding normally instead of erroring — no re-download. **The recheck reads
|
||||
the whole file over NFS and is slow** (minutes per multi-GB file) — kick off
|
||||
several in parallel rather than waiting on each one serially, and poll with:
|
||||
|
||||
```bash
|
||||
bash ~/.claude/plugins/cache/claude-homelab/homelab-core/*/skills/qbittorrent/scripts/qbit-api.sh info <hash>
|
||||
```
|
||||
|
||||
For a multi-season show downloaded as separate per-season torrents (e.g.
|
||||
Babylon 5), run `qbt-relink.sh` once per season/torrent, pointing each at its
|
||||
own `Season NN` folder — don't try to relink multiple torrents to one shared
|
||||
show-root folder, since the tool matches file counts 1:1 between the torrent
|
||||
and the destination folder.
|
||||
|
||||
Credentials (`QBITTORRENT_URL`/`USERNAME`/`PASSWORD`) live in
|
||||
`~/.claude-homelab/.env` (the claude-homelab plugin's credential file), not
|
||||
this repo's `.credentials` — `qbt-relink.sh` sources that file directly.
|
||||
|
||||
## Verifying the Plex side (do this every time, not just once)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user