Skip to content

Running Torrents Day to Day

Outcome: the handful of operations you actually perform on torrents after they exist — stop, start, recheck, inspect, and delete — each with the state change it should produce. Evidence: transcripts t07, t10, t11.

Stop and start (and a rename worth knowing)

Older guides — and older scripts of yours — will call torrents/pause and torrents/resume. In this version those addresses are gone: the lab's call to pause answered 404 (t07). The verbs are now torrents/stop and torrents/start:

curl -s -b cookies.txt --data 'hashes=<info hash>' \
  http://127.0.0.1:18089/api/v2/torrents/stop

A stopped complete torrent reports stoppedUP; started again, it returns to stalledUP. State changes trail the call by a second or so — poll, do not assume the first read after a verb is the verdict. A stopped torrent keeps its place, its data and its settings; it simply does nothing, which is exactly what you want before moving files around or shutting down.

Recheck: making the client re-read the disk

Files change behind a client's back — a tidier moves them, a disk corrupts them. torrents/recheck orders a full re-verification, and the lab caught it mid-flight (t07):

state=stalledUP  progress=1
state=checkingUP progress=0
state=stalledUP  progress=1

Progress drops to zero while pieces are re-proven, then returns to what the disk actually justifies. If a file was damaged, the recheck ends lower than it began and the missing pieces become ordinary downloading again. A recheck that ends at 1 is the strongest statement a client can make about its own data short of the whole-file hash of chapter 7.

Reading one torrent closely

Three reads, three depths (t07, t11):

  • torrents/info — the list view: state, progress, speeds, counts, category, tags. The everyday one.
  • torrents/files?hash=... — the contents: each file's size, its own progress, and its priority (1 here; priorities are how you tell a client this file first, that one never — the lab lists the value, and the changing of it is documented-only).
  • torrents/properties?hash=... — the deep record: total size, piece count and piece size (8 pieces of 262144 for the lab's fixture — matching chapter 6's map exactly), the info hash, and the comment the lab wrote into the map, carried through untouched.

And one read for the whole program: sync/maindata returns every torrent plus a server_state — the call things that watch qBittorrent poll. The lab's snapshot shows connection_status: "firewalled", which is the program's honest report that its torrenting port is not reachable from the public internet — true in the sandbox, and on a home machine the sign that a router port-forward is missing (chapter 13).

Delete: two operations wearing one name

torrents/delete takes deleteFiles, and the difference is the whole point (t10):

  • deleteFiles=false — the torrent leaves the list; the data stays on disk. The lab deleted two torrents from B and then showed B's folder: the downloaded field-notes.txt, 2097152 bytes, still there.
  • deleteFiles=true — the list entry and the files go.

Choose consciously, every time: the first is housekeeping, the second is destruction, and the API will not ask you twice. Deleting is also how a mistake is cleared — the phantom magnet of chapter 6 left by the same door it came in.