fix: add safety check to force state update after symlink processing
All checks were successful
CI/CD / Build & Push Docker Image (push) Successful in 1m16s

Add a fallback in onSuccess that ensures the torrent state is set to
'pausedUP' after updateTorrent returns. This catches edge cases where
updateTorrent might not set the state correctly.

The check:
1. Verifies state after updateTorrent returns
2. If state is not 'pausedUP' but we have a valid symlink path, force update
3. Logs a warning with diagnostic info when fallback triggers

This should definitively fix the TorBox downloads stuck in 'downloading'
state issue (dcy-355).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 11:47:43 -08:00
committed by John Ogle
parent 3f96382e76
commit 4cf8246550

View File

@@ -133,6 +133,21 @@ func (s *Store) processFiles(torrent *Torrent, debridTorrent *types.Torrent, imp
Msg("onSuccess called")
torrent.TorrentPath = torrentSymlinkPath
s.updateTorrent(torrent, debridTorrent)
// Safety check: ensure state is set correctly after updateTorrent
// This catches any edge cases where updateTorrent doesn't set the state
if torrent.State != "pausedUP" && torrentSymlinkPath != "" {
s.logger.Warn().
Str("torrent_name", debridTorrent.Name).
Str("current_state", torrent.State).
Str("debrid_status", debridTorrent.Status).
Msg("State not pausedUP after updateTorrent, forcing state update")
torrent.State = "pausedUP"
torrent.Progress = 1.0
torrent.AmountLeft = 0
s.torrents.Update(torrent)
}
s.logger.Info().Msgf("Adding %s took %s", debridTorrent.Name, time.Since(timer))
go importReq.markAsCompleted(torrent, debridTorrent) // Mark the import request as completed, send callback if needed