feat: add .torrent-first submission flow with persisted tracker policy - #389
Open
buzzromain wants to merge 10 commits into
Open
buzzromain wants to merge 10 commits into
buzzromain wants to merge 10 commits into
Conversation
GetMagnetFromFile and GetMagnetFromUrl no longer take rmTrackerUrls —
since "apply tracker policy at debrid submission only" the stripping
happens in GetTorrentInfo/GetMagnetInfo, called just before handing the
magnet to a provider.
The Strip{True,False} pairs are kept and now route through
applyTrackerPolicy, which mirrors what the manager does at submission,
so the end-to-end behaviour stays covered.
AddNewTorrent saved the .torrent before queueing, but the retry path added upstream — queueTorrentRetry, taken when the provider reports too many active downloads — queued the entry without saving anything. The Fixer then had no file to re-insert with, precisely for the torrents held back because the provider was saturated. Both paths now call persistTorrentFile just before queue.Add. Keeping it there rather than before the debrid submission avoids orphaning a file when submission fails outright, since Storage.Delete is what removes it.
doPostMultipart discarded the response body before SubmitMagnet's multipart branch could use it, so a real API rejection only ever surfaced as "Status: %d" — unlike the magnet-link branch, which already included the body. Threads the body through so both branches report the same amount of detail on failure.
RmTrackerUrls only lived on the short-lived ImportRequest, so reinsertion (fixer.go) and queue-rebuild (active_queue.go) could only ever consult the current global always_rm_tracker_urls setting — a torrent added with "remove tracker URLs" checked one-off silently lost that choice the moment it needed to be resubmitted. Entry gains a persisted RmTrackerUrls field (EntryProto field 40), set at creation from the original request and honoured alongside the global setting on every later resubmission.
No test exercised SaveTorrentFile/LoadTorrentFile/DeleteTorrentFile. The reinsertion path treats a load failure as "fall back to magnet" rather than a hard error, so a round-trip bug here would silently degrade reinsertions instead of surfacing anywhere obvious.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
.torrent-first submission flow while keeping full backward compatibility with magnet-link workflows:use_torrent_fileconfig option (defaulttrue, backward-compatible): when a.torrentfile is available, upload it directly to the debrid provider instead of only sending a magnet link. Improves re-insertion reliability, since a.torrentfile carries metadata a bare magnet link doesn't..torrentbytes: the file is saved to disk on submission and reloaded on later reinsertion (repair, managed-only auto-reinsertion), so reinsertion doesn't have to fall back to a magnet-only resubmission..torrentupload support added across AllDebrid, DebridLink, RealDebrid, and Torbox.remove tracker URLs) is now preserved on the entry itself, so it's honoured again on reinsertion/queue-rebuild instead of only reflecting the current global setting.Changes
internal/config/debrid.go—use_torrent_filefield, defaults totrueinternal/utils/magnet.go—.torrentparsing/sanitization helpers (GetTorrentInfo)pkg/storage/torrent_files.go— save/load/delete.torrentbytes on disk, keyed by infohashpkg/storage/types.go,proto.go,storage.proto,storage.pb.go— persistedRmTrackerUrlsfield onEntrypkg/debrid/providers/{alldebrid,realdebrid,debridlink,torbox}—.torrentupload supportpkg/manager/{processor,fixer,active_queue}.go— wiring into submission, reinsertion, and queue-rebuildpkg/server/api.go,pkg/server/qbit/torrent.go— API surface for.torrentuploadsinternal/utils/magnet_test.go(extended),pkg/storage/torrent_files_test.go,pkg/manager/tracker_policy_test.go,pkg/debrid/providers/debridlink/debrid_link_test.goConfiguration example
{ "debrids": [ { "provider": "realdebrid", "api_key": "...", "use_torrent_file": true } ] }