Skip to content

[BUG] TorBox: download fails on first poll when finished but not yet present #1403

Closed

Description

@IbbyLabs

Bug Description

With TorBox as the torrent client, a download can fail on its first status poll with TorBox finished processing but the download is unavailable, even though TorBox completes it a few seconds later. Requesting the same release again then works immediately.

shelfmark/download/clients/torbox.py, _handle_torrent_status:

finished = torrent.get("download_finished") is True
present = torrent.get("download_present") is True
if finished and not present:
    message = "TorBox finished processing but the download is unavailable"
    self._set_error(state, message)
    return DownloadStatus.error(message)

For a torrent TorBox already has cached, download_finished can be true a moment before download_present becomes true. That window is normal, but this branch treats it as terminal on the first poll it sees it, so the task errors out instead of polling again.

Steps To Reproduce

  1. Configure TorBox as the torrent client and AudiobookBay as a source.
  2. Download an audiobook release (cached on TorBox).
  3. About 10-20 s after Added torrent to TorBox, the task fails with the message above and cleanup is skipped.
  4. Query TorBox GET /v1/api/torrents/mylist?id=<id>: the same torrent now shows download_state: completed, download_finished: true, download_present: true, progress: 1.
  5. Request the same release again: it completes and imports normally.

Seen on two different releases in a row (TorBox ids created 2 minutes apart), both failing within ~20 s of being added and both showing as complete and present on TorBox straight afterwards.

Expected Behavior

finished and not present is treated as still processing (keep polling, with a timeout), and only becomes an error if the file never becomes present.

Debug Information

Log excerpt:

INFO  torbox.py:167 - Added torrent to TorBox: ID 107108061
INFO  base_handler.py:871 - Added to torbox: 107108061 for 'Artemis'
ERROR base_handler.py:1006 - Download 107108061 error state: TorBox finished processing but the download is unavailable
INFO  base_handler.py:426 - Skipping download client cleanup for protocol=torrent after download error (client=torbox id=107108061)

Environment Information

  • BASE OS: Ubuntu 24.04 (Docker)
  • Image: ghcr.io/calibrain/shelfmark:dev (revision d2b4a02)

Additional Context

The retry succeeding immediately suggests it's only the first-poll timing, not TorBox availability.

Activity

  1. calibrain commented on Oct 3, 2026

    @calibrain
    Owner

    Fixed in #1422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions