Repository navigation
fix: SABnzbd duplicates no longer fail the request, and a retried upload is not added twice - #480
Merged
Merged
Conversation
… add reuses the first upload When SABnzbd discards, pauses or fails an NZB as a duplicate, RMAB finds the job it already holds by name and category: a queued or post-processing job is tracked, a finished job whose files are on disk after path mapping is imported through the normal completion path, and otherwise the release is blocklisted and the next one is tried. A Bull retry after a timed-out upload looks for the earlier job before uploading again. Closes #329. Co-authored-by: thehaven <420380+thehaven@users.noreply.github.com> Co-authored-by: connor2k <connormiddleton@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… resume only RMAB's paused job (#329) - Request delete leaves a taken-over usenet job alone (already, via the ownership check) and now keeps RMAB's own job while another active request tracks the same nzo_id; remove-after-processing keeps the files of a job recorded addedByRmab false. - The existing-job lookup matches the release title, or the upload name only when it is specific: never download/api or a name that shares no word with the release title. - A held job that waits paused is resumed only when RMAB added it for an earlier download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kikootwo
marked this pull request as ready for review
October 27, 2026 11:25
This was referenced Oct 27, 2026
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.
Closes #329
What changed
src/lib/integrations/sabnzbd-duplicates.ts: finds the job SABnzbd already holds for an NZB and decides what to do with it. A job matches when its name equals the release title the processor passes (releaseTitle) or the upload name, letters and digits compared ignoring case, in the same category, with failed jobs skipped. It looks in the queue first, then history, then the history archive. The upload name only counts when it is specific: never a generic name (download, the fallback for a Prowlarr/downloadURL without Content-Disposition, orapi,nzb,get,file,index, a bare number), and only when it shares a word with the release title. With no usable name, the response is handled as onmain. A queued, downloading or post-processing job is tracked as the request's download. A finished job is tracked only when itsstoragepath exists after remote path mapping, so the monitor's normal completion path imports it. A finished job whose files are gone raisesUnusableDownloadSourceErrorwith ablocklistReason.SABnzbdService.addNZBJob()(addNZB()andaddDownload()go through it):{status: false, nzo_ids: []}) runs the lookup. With nothing found, the error is the same as before.Duplicate NZBrow) and uses the existing job.retry: true, the lookup runs after the NZB is fetched and before the upload, and a usable job is reused instead of uploading a second copy.addDownload()returnsalreadyInClient: truefor a reused job, so the row is recordedaddedByRmab: false.getNZB(): when the job is not in the queue or the newest 100 history rows, it looks the job up bynzo_ids, then in the archive. A taken-over job can be older or archived.download-torrent.processor.ts: anUnusableDownloadSourceErrorwith ablocklistReasonblocklists the release (addAutoBlock,download_fail) before the next ranked release is tried, the same loop a failed grab uses. On a Bull retry (job.attemptsMade > 0, passed in byjob-queue.service.ts) it addsretry: trueto the add options, and usenet adds getreleaseTitle. A held job SABnzbd reports as paused (paused: true) is resumed only when a download row for that nzo_id says RMAB added it (addedByRmab: true). Any other paused job is tracked as it is, with a warning to resume it in SABnzbd.addedByRmab: falsebefore any client call, and that is now covered by a test. RMAB's own usenet job is now also kept while another active request tracks the same nzo_id (otherActiveRequestsUsingNzb()insrc/lib/utils/shared-torrent.ts, counted as kept-shared, like the torrent guard). Remove-after-processing (planDownloadCleanup()inorganize-cleanup-guard.ts) makes no plan for a row recordedaddedByRmab: false, so the job's files stay. The stale "always RMAB's" comment is gone.documentation/phase3/sabnzbd.md(new "Duplicate NZBs and Retried Adds" section with the response table, lookup names, ownership, history params, Fixed Issue 9),documentation/phase3/download-clients.md,documentation/admin-features/request-deletion.md,documentation/phase3/file-organization.md,documentation/TABLEOFCONTENTS.md.Why
SABnzbd's "Detect duplicate downloads" treats a job as a duplicate when a non-failed history row (archived rows included) or a queued job has the same name or the same NZB md5. RMAB archives every job it imports, so asking again for a release RMAB downloaded before is a duplicate. What happened next depended on the mode:
addfileanswer{status: true, nzo_ids: [new]}{status: false, nzo_ids: []}, nothing added{status: true, nzo_ids: [new]}, new job paused{status: true, nzo_ids: [new]}, history rowFailed, "Duplicate NZB"{status: true, nzo_ids: [new]}, downloadingOn SABnzbd 4.2 and later, a copy already in the queue makes the new job paused in every mode except Off and Tag. The
nzo_idsin the answer always name the new job, never the existing one, so the existing job has to be found by name and category.Separately, an
addfileupload that times out is a transient error, so Bull re-runs the whole download job (3 attempts). The retry uploaded the NZB again even when SABnzbd had accepted the first upload. The result was a second copy, or a duplicate refusal for a job the request never tracked.Evidence
tests/fixtures/sabnzbd-duplicates.tspins theaddfileanswer and what each mode leaves behind, read from SABnzbd 4.0 to 5.x source (api._api_addfile,nzbparser.process_single_nzb,NzbObject.handle_duplicate_action).tests/integrations/sabnzbd-duplicates.test.tsruns the realSABnzbdServiceagainst a stateful fake SABnzbd API (queue, history, archive, its search wildcards) and real directories for the files check:Duplicate NZBrow is archived; without files the release is rejected./downloadURL with no Content-Disposition (upload namedownload.nzb) does not match another book's queued or archiveddownloadjob, on a retry or in Discard mode. An upload name that shares no word with the release title does not match either. A job named as the release title is still found.paused: true.tests/processors/download-torrent-duplicate.test.ts: a rejected duplicate is blocklisted (release name, indexer, reason, job) and the next release is grabbed; a taken-over job is recordedaddedByRmab: falseand monitored; an unusable source without a reason is skipped without blocklisting, unchanged; a Bull retry passesretry: trueand a first attempt does not.tests/services/request-delete.usenet-ownership.test.ts: a taken-over SABnzbd job and its files survive request delete. RMAB's own job is kept while another active request tracks it, and is deleted with its files when none does.tests/processors/organize-cleanup-guard.takeover.test.ts: no remove-after-processing plan for a taken-over job; RMAB's own job (true, or a legacynull) still gets one.main'ssrc(f182a0d) and the first round's tests: 15 failed, 12 passed, all on an assertion. With the first round'ssrcmerged withmain(599d48b) and this branch's tests: 9 failed, 32 passed, all on an assertion (the generic-name, release-title, paused-job, shared-job and cleanup cases). On this branch: 41/41 pass.Checks
vitest relatedon the 8 changed source files, plus the 4 test files): PASS, 141 files, 2061/2061tsc --noEmitclean; ESLint finds nothing new in the touched files compared withmain, and the 6 new files are clean)src/libonlyRisk and rollback
Release note
🤖 Generated with Claude Code