Commit Graph
12 Commits
Author SHA1 Message Date
mnightingale f372698127 Write the queue admin once per batch when removing or adding many jobs 2026-09-10 11:47:34 +02:00
mnightingale 2db268e9a6 Insert queued jobs with bisect and queue each priority group in arrival order 2026-09-10 11:47:34 +02:00
mnightingale b69bd10725 Add tests covering NzbQueue add, remove, reorder, priority and sorting 2026-09-10 11:47:34 +02:00
Safihre 93546e5b7a Add SafeUnpickler to guard against pickle-attacks (#3585)
* Add SafeUnpickler to guard against pickle-attacks

* Harden pickle unpickler with explicit allowlist

The previous `SafeUnpickler` allowed any class from `sabnzbd.*` by wildcard, which could still enable deserialization attacks if a "gadget class" (e.g., with a malicious `__del__` method) was present within our own package.

This commit renames the class to `RestrictedUnpickler` and changes its logic to only allow classes explicitly defined in `_SAFE_GLOBALS`. This significantly enhances security by preventing the unpickling of any unlisted classes, including those from within `sabnzbd`. Adds `os.stat_result` and `sabnzbd.nzb.*` classes to the allowlist for compatibility.
2026-08-24 22:40:04 +02:00
mnightingale 73af985e60 Optimise scanning for orphan jobs and retry all (#3492)
* Optimise scanning for orphan jobs and retry all

* Require start and limit for build_history
2026-07-13 09:26:17 +02:00
mnightingale 228e7e650e Implement article-level retry (#3435)
* Implement article-level retry

* Remove count because bit_count is 3.10

* Fix errors importing files without article db

* Fix bookkeeping of bytes downloaded and on_disk status for complete existing files

* Legacy queue tests

* Bitmap types

* Add docs to Bitmap

* Match renamed files

* Add repair_job tests

* Need to remember failed state

* Only finish_import when required and defer setting on_disk state

* KISS

Closes #2735
2026-06-19 09:10:19 +02:00
Safihre 0950393b82 Correctly format tests based on new rules and remove star imports 2026-06-05 14:34:17 +02:00
Ryan HollisterandClaude Sonnet 4.6 25d20f0f08 Fix RuntimeError: dictionary changed size during iteration in stop_idle_jobs (#3432)
* Fix RuntimeError from dict mutation in stop_idle_jobs (#3431)

Collecting exhausted articles into a snapshot list while holding
nzf.lock, then calling register_article outside the iteration.
This prevents RuntimeError when register_article -> nzf.remove_article
pops from nzf.articles (a dict) while stop_idle_jobs is iterating it.

The original code in fd3ece31c used `nzf.articles[:]` which was safe
when articles was a list. When 44d94226e changed articles to a dict
the protective copy was dropped, leaving bare dict iteration that
mutates mid-loop.

The collect-then-act pattern matches nzf_remove_list in nzb/object.py
and the empty-nzo list already used in stop_idle_jobs itself. It also
correctly calls register_article outside nzf.lock, consistent with its
own "not locked for performance" contract.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Apply Black formatting to nzbqueue.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Soften comment per maintainer feedback

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 22:33:14 +02:00
Safihre 98dc183881 Add test for 3.0.0 legacy queue format restoration
Moved sys.modules call higher, so it is always applied
2026-05-04 17:04:03 +02:00
Safihre 2122503762 Update copyright to 2026 2026-02-09 16:44:38 +01:00
Safihre 3384beed24 Make black 26.1.0 happy again - almost 2026-01-19 12:42:51 +01:00
mnightingale 3e7dcce365 Fix queue cannot be loaded (#3271)
* Fix queue cannot be restored

* Also change init

* Add a test

Fixes #3269
2026-01-12 09:54:59 +01:00