From 2a3e0773f6d58bf6c6755895cfbe9bb2d1d6ddf8 Mon Sep 17 00:00:00 2001 From: xbmc4lyfe <273732874+xbmc4lyfe@users.noreply.github.com> Date: Sat, 5 Dec 2026 15:27:23 -0600 Subject: [PATCH] deps/fix: roll in zipfast::zipview (#849) and queue/pacing/pressure/docs fixes Rebases PR #850 cleanly onto main (57ba238f2, after #845, #846, #847, and #851 landed), rolls in PR #849, and includes follow-up hardening and documentation validation fixes: - #849 (zipview-to-zipfast): switch unpack.rs and streamrepair.rs to zipfast::zipview (c7ee07dbf4c9817bb8d0dbf07684c643932a96e5) and drop the standalone archived zipview crate (keeping #851's nntp-rs pin cf5df57ac49c6709ddde86f3f7eeff49e032821d; 1 zipview package in Cargo.lock). - #845 follow-up (rust/src/qqueue.rs): use Ordering::SeqCst on RawLock::try_take CAS failure so ARM64 / weak memory models keep the Dekker store-load pair against unlock(). - #846 follow-up (rust/src/queuecoord.rs, site/, site/content/): - Update site/build.py (validate_config_js_options) and site/check.py to verify every option in webui/config.js LAYOUT and OPTION_REQUIRES has an options.html anchor; - Fix Vale Google.Quotes and Google.OxfordComma findings in site/content/api.md and site/content/settings-processing.md; - Update queuecoord::pick_next_article and Coordinator::run() (excluded_nzbs retry, deferred apply_pick_yield after conn_ptr != 0, and PostStrategy=sequential exemption for unpack-paced downloads) so desired_server_id exhaustion skips to other work or falls back cleanly without falsely unpacing the yielding download. - #847 follow-up (rust/src/articledl.rs): clamp MEM_SLOT_TIER down immediately whenever (slot_current as i32) > next_tier (resetting MEM_SLOT_GATE) and fall back to decision.cache_source for attribution. --- rust/Cargo.lock | 17 +- rust/Cargo.toml | 3 +- rust/src/articledl.rs | 24 ++- rust/src/qqueue.rs | 2 +- rust/src/queuecoord.rs | 306 ++++++++++++++++++++-------- rust/src/streamrepair.rs | 1 + rust/src/unpack.rs | 1 + site/build.py | 31 +++ site/check.py | 15 ++ site/content/api.md | 4 +- site/content/settings-processing.md | 2 +- 11 files changed, 294 insertions(+), 112 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 81d6c806b..d6c712803 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -547,7 +547,6 @@ dependencies = [ "quick-xml", "vidmatch", "zipfast", - "zipview 0.1.0 (git+https://github.com/xbmc4lyfe/zipview?rev=2c3d73a06b29987cea1510e903e437a482076745)", "zstd", ] @@ -1059,12 +1058,12 @@ dependencies = [ [[package]] name = "zip-container" version = "0.1.0" -source = "git+https://github.com/Appz4Fun/zipfast?rev=fa031ee751ee294d6fb589b6caa1e986de3fdf1b#fa031ee751ee294d6fb589b6caa1e986de3fdf1b" +source = "git+https://github.com/Appz4Fun/zipfast?rev=c7ee07dbf4c9817bb8d0dbf07684c643932a96e5#c7ee07dbf4c9817bb8d0dbf07684c643932a96e5" [[package]] name = "zipfast" version = "0.1.0" -source = "git+https://github.com/Appz4Fun/zipfast?rev=fa031ee751ee294d6fb589b6caa1e986de3fdf1b#fa031ee751ee294d6fb589b6caa1e986de3fdf1b" +source = "git+https://github.com/Appz4Fun/zipfast?rev=c7ee07dbf4c9817bb8d0dbf07684c643932a96e5#c7ee07dbf4c9817bb8d0dbf07684c643932a96e5" dependencies = [ "bzip2", "crc32fast", @@ -1077,22 +1076,14 @@ dependencies = [ "subtle", "tempfile", "zip-container", - "zipview 0.1.0 (git+https://github.com/Appz4Fun/zipfast?rev=fa031ee751ee294d6fb589b6caa1e986de3fdf1b)", + "zipview", "zstd", ] [[package]] name = "zipview" version = "0.1.0" -source = "git+https://github.com/xbmc4lyfe/zipview?rev=2c3d73a06b29987cea1510e903e437a482076745#2c3d73a06b29987cea1510e903e437a482076745" -dependencies = [ - "flate2", -] - -[[package]] -name = "zipview" -version = "0.1.0" -source = "git+https://github.com/Appz4Fun/zipfast?rev=fa031ee751ee294d6fb589b6caa1e986de3fdf1b#fa031ee751ee294d6fb589b6caa1e986de3fdf1b" +source = "git+https://github.com/Appz4Fun/zipfast?rev=c7ee07dbf4c9817bb8d0dbf07684c643932a96e5#c7ee07dbf4c9817bb8d0dbf07684c643932a96e5" dependencies = [ "flate2", "subtle", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 9a75de724..01a29a49e 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -21,9 +21,8 @@ doctest = false [dependencies] par-rs = { git = "https://github.com/Appz4Fun/par-rs", rev = "e471c49a29f9ee40af9bd0bf60b7dec63cf74a4b" } -zipfast = { git = "https://github.com/Appz4Fun/zipfast", rev = "fa031ee751ee294d6fb589b6caa1e986de3fdf1b", features = ["persistent-partials"] } +zipfast = { git = "https://github.com/Appz4Fun/zipfast", rev = "c7ee07dbf4c9817bb8d0dbf07684c643932a96e5", features = ["persistent-partials"] } vidmatch = { git = "https://github.com/Appz4Fun/vidmatch", rev = "819206601b780f314081225d8156843787ea082d" } -zipview = { git = "https://github.com/xbmc4lyfe/zipview", rev = "2c3d73a06b29987cea1510e903e437a482076745" } # nntp-rs v0.4.4+ (one-pass yEnc decode) nntp-rs = { git = "https://github.com/Appz4Fun/nntp-rs", rev = "cf5df57ac49c6709ddde86f3f7eeff49e032821d", default-features = false, features = ["blocking", "openssl"] } crc32fast = "1.5" diff --git a/rust/src/articledl.rs b/rust/src/articledl.rs index 07e310df1..79b97cc6a 100644 --- a/rust/src/articledl.rs +++ b/rust/src/articledl.rs @@ -525,12 +525,17 @@ fn memory_monitor_update_state() -> i32 { let slot_current = PressureTier::from_i32(MEM_SLOT_TIER.load(Ordering::Relaxed)); let (slot_next, slot_changed) = { let mut gate = MEM_SLOT_GATE.lock().unwrap_or_else(|e| e.into_inner()); - mp::slot_gate_step( - slot_raw, - slot_current, - &mut gate, - mp::slot_persist_samples(interval), - ) + if (slot_current as i32) > next_tier { + *gate = Default::default(); + (PressureTier::from_i32(next_tier), true) + } else { + mp::slot_gate_step( + slot_raw, + slot_current, + &mut gate, + mp::slot_persist_samples(interval), + ) + } }; if transitioned { @@ -557,7 +562,12 @@ fn memory_monitor_update_state() -> i32 { if slot_changed { MEM_SLOT_TIER.store(slot_next as i32, Ordering::Release); - let why = mp::describe_source(decision.slot_source, &metrics, budget); + let src = if decision.slot_source == mp::PressureSource::None { + decision.cache_source + } else { + decision.slot_source + }; + let why = mp::describe_source(src, &metrics, budget); let msg = match slot_next { PressureTier::Critical => { format!("Memory pressure persisted ({why}): download slots cut to a quarter") diff --git a/rust/src/qqueue.rs b/rust/src/qqueue.rs index e176e1432..5e6e92d45 100644 --- a/rust/src/qqueue.rs +++ b/rust/src/qqueue.rs @@ -85,7 +85,7 @@ impl RawLock { #[inline] fn try_take(&self) -> bool { self.locked - .compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed) + .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst) .is_ok() } diff --git a/rust/src/queuecoord.rs b/rust/src/queuecoord.rs index af2c048cf..06bc0726b 100644 --- a/rust/src/queuecoord.rs +++ b/rust/src/queuecoord.rs @@ -3774,66 +3774,90 @@ impl NzbgetRsQueueCoordinator { host.with_locked_queue(|dq_ptr| { let opts = host.opts(); let pass_start = std::time::Instant::now(); + let mut conn_blocked: Vec = Vec::new(); for n in 0..MAX_STARTS_PER_PASS { - if n > 0 && pass_start.elapsed() >= MAX_START_PASS_TIME { - break; - } - let next_pair = self.get_next_article(host, &opts, dq_ptr); - // The download next in line waits while its dead-pick probe waits for a - // connection (see `dupeprobe::probe_waiting_for_connection`): the connection it - // would take goes to the probe. Nothing of lower priority takes it meanwhile - // (a fleet's primary stays first), and the queue stays busy (`PROBE_HELD`). - let held = next_pair.as_ref().is_some_and(|(file, _)| { - crate::dupeprobe::probe_waiting_for_connection( - host.nzb_snap(file.nzb_ptr, false).id, - ) - }); - PROBE_HELD.store(held, std::sync::atomic::Ordering::Relaxed); - let next_pair = if held { None } else { next_pair }; - let has_more_articles = next_pair.is_some() || held; - let active_len = host.active_downloads_len(); - article_downloads_running = active_len > 0; - host.self_set_has_more_jobs(has_more_articles || article_downloads_running); - - let dl_limit = self - .downloads_limit - .load(std::sync::atomic::Ordering::Relaxed); - let effective_limit = host.effective_downloads_limit(dl_limit); - let can_proceed = - !host.self_is_stopped() && (active_len as i32) < effective_limit; + let mut started_this_slot = false; + loop { + if (n > 0 || !conn_blocked.is_empty()) + && pass_start.elapsed() >= MAX_START_PASS_TIME + { + break; + } + let mut yielded: Vec<(i32, NzbRef)> = Vec::new(); + let (next_pair, used_paced_fallback) = self.pick_next_article( + host, + &opts, + dq_ptr, + &conn_blocked, + &mut yielded, + ); + // The download next in line waits while its dead-pick probe waits for a + // connection (see `dupeprobe::probe_waiting_for_connection`): the connection it + // would take goes to the probe. Nothing of lower priority takes it meanwhile + // (a fleet's primary stays first), and the queue stays busy (`PROBE_HELD`). + let held = next_pair.as_ref().is_some_and(|(file, _)| { + crate::dupeprobe::probe_waiting_for_connection( + host.nzb_snap(file.nzb_ptr, false).id, + ) + }); + PROBE_HELD.store(held, std::sync::atomic::Ordering::Relaxed); + let next_pair = if held { None } else { next_pair }; + let has_more_articles = + next_pair.is_some() || held || !conn_blocked.is_empty(); + let active_len = host.active_downloads_len(); + article_downloads_running = active_len > 0; + host.self_set_has_more_jobs( + has_more_articles || article_downloads_running, + ); - let Some((file, art)) = next_pair else { - break; - }; - if !(can_proceed && (!opts.download_held || file.extra_priority)) { + let dl_limit = self + .downloads_limit + .load(std::sync::atomic::Ordering::Relaxed); + let effective_limit = host.effective_downloads_limit(dl_limit); + let can_proceed = + !host.self_is_stopped() && (active_len as i32) < effective_limit; + + let Some((file, art)) = next_pair else { + break; + }; + if !(can_proceed && (!opts.download_held || file.extra_priority)) { + break; + } + let nzb = host.nzb_snap(file.nzb_ptr, false); + let conn_ptr = host.server_pool_get_connection( + nzb.has_desired_server, + nzb.desired_server_id, + ); + if conn_ptr != 0 { + apply_pick_yield(file.nzb_ptr, used_paced_fallback, &yielded); + downloads_checked = true; + article_downloads_running = true; + download_started = true; + self.start_dead_pick_probe(host, &opts, dq_ptr, &nzb); + self.start_article_download(host, &opts, &nzb, &file, &art, conn_ptr); + started_this_slot = true; + break; + } + if nzb.has_desired_server && !conn_blocked.contains(&file.nzb_ptr) { + let mut dbg = b"Could not start download for ".to_vec(); + dbg.extend_from_slice(&nzb.name); + dbg.extend_from_slice( + format!( + ": desired server {} has no available connections", + nzb.desired_server_id + ) + .as_bytes(), + ); + host.log(crate::queuesubsys_host::MK_DEBUG, &dbg); + conn_blocked.push(file.nzb_ptr); + continue; + } + // No connection free: the rest waits for the next pass. break; } - let nzb = host.nzb_snap(file.nzb_ptr, false); - let conn_ptr = host.server_pool_get_connection( - nzb.has_desired_server, - nzb.desired_server_id, - ); - if conn_ptr != 0 { - downloads_checked = true; - article_downloads_running = true; - download_started = true; - self.start_dead_pick_probe(host, &opts, dq_ptr, &nzb); - self.start_article_download(host, &opts, &nzb, &file, &art, conn_ptr); - continue; - } else if nzb.has_desired_server { - let mut dbg = b"Could not start download for ".to_vec(); - dbg.extend_from_slice(&nzb.name); - dbg.extend_from_slice( - format!( - ": desired server {} has no available connections", - nzb.desired_server_id - ) - .as_bytes(), - ); - host.log(crate::queuesubsys_host::MK_DEBUG, &dbg); + if !started_this_slot { + break; } - // No connection free: the rest waits for the next pass. - break; } }); test_coord_pass_delay(); @@ -4552,6 +4576,7 @@ impl NzbgetRsQueueCoordinator { }); } + #[cfg(test)] fn get_next_article( &self, host: &crate::queuesubsys_host::QueueSubsysHost, @@ -4562,31 +4587,32 @@ impl NzbgetRsQueueCoordinator { crate::queuesubsys_host::ArticleSnap, )> { let mut yielded: Vec<(i32, NzbRef)> = Vec::new(); - let picked = self.pick_next_article(host, opts, dq_ptr, &mut yielded); - // Another download took a connection a paced download passed over: that one's - // articles in flight stop sleeping at unpack speed for a while (`liveorder`). - if let Some((f, _)) = &picked { - for &(id, ptr) in &yielded { - if ptr != f.nzb_ptr { - crate::liveorder::note_unpack_yield(id); - } - } + let (picked, used_paced_fallback) = + self.pick_next_article(host, opts, dq_ptr, &[], &mut yielded); + if let Some((ref f, _)) = picked { + apply_pick_yield(f.nzb_ptr, used_paced_fallback, &yielded); } picked } - /// `get_next_article`'s pick; `yielded` gets the downloads paced to their direct unpack - /// whose volumes it passed over for another download's. + /// `get_next_article`'s pick, side-effect-free with respect to `liveorder` yield state so + /// the coordinator can retry around `desired_server_id` exhaustion before committing yield. + /// Returns `(picked, used_paced_fallback)`; callers invoke `apply_pick_yield` only once a + /// connection is actually acquired for the picked article. fn pick_next_article( &self, host: &crate::queuesubsys_host::QueueSubsysHost, opts: &crate::queuesubsys_host::GlobalOptsSnap, dq_ptr: usize, + excluded_nzbs: &[NzbRef], yielded: &mut Vec<(i32, NzbRef)>, - ) -> Option<( - crate::queuesubsys_host::FileSnap, - crate::queuesubsys_host::ArticleSnap, - )> { + ) -> ( + Option<( + crate::queuesubsys_host::FileSnap, + crate::queuesubsys_host::ArticleSnap, + )>, + bool, + ) { let mut checked_files: Vec = Vec::new(); let cur_date = opts.cur_time; // Downloads extracted live, by id: their volumes' extraction order and the lowest @@ -4602,10 +4628,6 @@ impl NzbgetRsQueueCoordinator { let queue: Vec = (0..host.queue_len(dq_ptr)) .map(|i| PickEntry::read(host, host.queue_at(dq_ptr, i), i)) .collect(); - // Under PostStrategy=Sequential (0), finish downloading the active NZB before starting - // another at equal or lower priority (higher-priority / Force / extra_priority still pass). - // Ignore fully-paused NZBs whose already-in-flight articles are merely winding down. - let seq_active_priority = sequential_active_priority(opts.post_strategy, &queue); // The queue's copies by duplicate key, indexed once per call when first needed (see // `has_active_dupe`). let mut copies_by_key: Option = None; @@ -4615,8 +4637,20 @@ impl NzbgetRsQueueCoordinator { // (its volumes ahead of unpack are passed over) while another download can use them. // When nothing else can, the pick goes round once more with pacing as before. let mut yield_paced = true; + let mut used_paced_fallback = false; loop { + // Under PostStrategy=Sequential (0), finish downloading the active NZB before starting + // another at equal or lower priority (higher-priority / Force / extra_priority still pass). + // Ignore fully-paused NZBs, downloads excluded in this pass (`conn_blocked`), and + // (during pass 1) unpack-paced downloads whose spare connections may go to the next job. + let seq_active_priority = sequential_active_priority( + opts.post_strategy, + &queue, + yield_paced, + excluded_nzbs, + |e| crate::liveorder::is_unpack_pacing(e.snap(host).id), + ); let mut best_file: Option<( crate::queuesubsys_host::NzbSnap, crate::queuesubsys_host::FileSnap, @@ -4660,6 +4694,7 @@ impl NzbgetRsQueueCoordinator { if nzb_higher && !nzb_paused + && !excluded_nzbs.contains(&nzb_ptr) && !budget_held.contains(&nzb_ptr) && !interdir_budget_skips(host, entry, cur_date) && !self.has_active_dupe(host, &queue, entry.snap(host), &mut copies_by_key) @@ -4755,9 +4790,7 @@ impl NzbgetRsQueueCoordinator { // before (their articles go out and sleep at unpack speed). if yield_paced && !yielded.is_empty() { yield_paced = false; - for (id, _) in yielded.drain(..) { - crate::liveorder::clear_unpack_yield(id); - } + used_paced_fallback = true; continue; } if let Some((pw_nzb, pw_file)) = prop_wait_file { @@ -4817,7 +4850,7 @@ impl NzbgetRsQueueCoordinator { if let Some((f1, a1)) = self.get_next_urgent_article(host, opts, &nzb) { self.propagation_wait_logged_id .store(0, std::sync::atomic::Ordering::Relaxed); - return Some((f1, a1)); + return (Some((f1, a1)), used_paced_fallback); } } @@ -4828,7 +4861,7 @@ impl NzbgetRsQueueCoordinator { if let Some((f1, a1)) = self.get_next_first_article(host, opts, &nzb) { self.propagation_wait_logged_id .store(0, std::sync::atomic::Ordering::Relaxed); - return Some((f1, a1)); + return (Some((f1, a1)), used_paced_fallback); } } @@ -4850,7 +4883,7 @@ impl NzbgetRsQueueCoordinator { } self.propagation_wait_logged_id .store(0, std::sync::atomic::Ordering::Relaxed); - return Some((file, art)); + return (Some((file, art)), used_paced_fallback); } if checked_files.capacity() < 100 { @@ -4859,7 +4892,7 @@ impl NzbgetRsQueueCoordinator { checked_files.push(file.ptr); } - None + (None, false) } /// An article a live extraction waits for before it can go on (see `liveorder::urge`): the @@ -10353,13 +10386,40 @@ fn interdir_budget_admits( } } } -fn sequential_active_priority(post_strategy: i32, queue: &[PickEntry]) -> Option { +fn apply_pick_yield(picked_nzb: NzbRef, used_paced_fallback: bool, yielded: &[(i32, NzbRef)]) { + if used_paced_fallback { + for &(id, _) in yielded { + crate::liveorder::clear_unpack_yield(id); + } + } else { + // Another download took a connection a paced download passed over: that one's + // articles in flight stop sleeping at unpack speed for a while (`liveorder`). + for &(id, ptr) in yielded { + if ptr != picked_nzb { + crate::liveorder::note_unpack_yield(id); + } + } + } +} + +fn sequential_active_priority( + post_strategy: i32, + queue: &[PickEntry], + yield_paced: bool, + excluded_nzbs: &[NzbRef], + is_paced: impl Fn(&PickEntry) -> bool, +) -> Option { if post_strategy != 0 { return None; } queue .iter() - .filter(|e| e.active_downloads > 0 && !e.is_paused()) + .filter(|e| { + e.active_downloads > 0 + && !e.is_paused() + && !excluded_nzbs.contains(&e.ptr) + && !(yield_paced && is_paced(e)) + }) .map(|e| e.priority) .max() } @@ -11756,7 +11816,7 @@ mod tests { let paused_active = mk(100, 1, 1, 1); let queued_b = mk(100, 3, 0, 0); assert_eq!( - super::sequential_active_priority(0, &[paused_active, queued_b]), + super::sequential_active_priority(0, &[paused_active, queued_b], true, &[], |_| false), None ); @@ -11764,13 +11824,16 @@ mod tests { let running_a = mk(100, 2, 1, 1); let queued_b2 = mk(100, 3, 0, 0); assert_eq!( - super::sequential_active_priority(0, &[running_a, queued_b2]), + super::sequential_active_priority(0, &[running_a, queued_b2], true, &[], |_| false), Some(100) ); // Non-sequential never gates. let running_a2 = mk(100, 2, 0, 1); - assert_eq!(super::sequential_active_priority(1, &[running_a2]), None); + assert_eq!( + super::sequential_active_priority(1, &[running_a2], true, &[], |_| false), + None + ); } #[test] @@ -11944,6 +12007,77 @@ mod tests { drop(opts_guard); } + #[cfg(unix)] + #[test] + fn paced_download_falls_back_under_sequential_when_replacement_desired_server_is_excluded() { + use crate::qnzb; + use crate::qqueue; + use crate::queuesubsys_host::QueueSubsysHost; + + let _s = qqueue::tests::serial(); + qqueue::daemon_queue_init(); + let opts_guard = crate::options::test_options(&[ + c"WriteLog=none", + c"LogBuffer=100", + c"PostStrategy=sequential", + ]); + let host = QueueSubsysHost::active(); + let qc = super::NzbgetRsQueueCoordinator::new(); + + let (nzb_a, id_a, files_a) = add_two_volume_download(&host, "PacedSeqA"); + crate::liveorder::set_order( + id_a, + &[ + b"PacedSeqA.part01.rar".to_vec(), + b"PacedSeqA.part02.rar".to_vec(), + ], + ); + crate::liveorder::test_force_paced(id_a, 45.0 * 1048576.0, 1700 << 20); + for i in 0..2 { + let art = host.article_at(files_a[0], i).ptr; + host.article_edit(art, crate::qarticle::ArticleEdit::Status(crate::qarticle::AI_RUNNING)); + } + // Even with ActiveDownloads > 0 under PostStrategy=sequential, a paced download + // yields spare connections to the next queued download. + qnzb::set_int(nzb_a, qnzb::NzbInt::ActiveDownloads, 1); + + let (nzb_b, _id_b, _files_b) = add_two_volume_download(&host, "BlockedDesiredB"); + + let (picked_first, fallback_first, yielded_first) = host.with_locked_queue(|dq_ptr| { + let opts = host.opts(); + let mut yielded = Vec::new(); + let (p, fb) = qc.pick_next_article(&host, &opts, dq_ptr, &[], &mut yielded); + (p.map(|(f, _)| f.nzb_ptr), fb, yielded) + }); + assert_eq!(picked_first, Some(nzb_b)); + assert!(!fallback_first); + assert_eq!(yielded_first, vec![(id_a, nzb_a)]); + // Coordinator gets conn_ptr == 0 for BlockedDesiredB's desired_server_id, so + // apply_pick_yield has NOT been called yet and PacedSeqA stays paced. + assert!(!crate::liveorder::is_unpack_yielding(id_a)); + + // Retrying the same pass with BlockedDesiredB excluded skips it and falls back + // to PacedSeqA while keeping PacedSeqA paced (not unpaced via note_unpack_yield). + let blocked = [nzb_b]; + let (picked_retry, fallback_retry, yielded_retry) = host.with_locked_queue(|dq_ptr| { + let opts = host.opts(); + let mut yielded = Vec::new(); + let (p, fb) = qc.pick_next_article(&host, &opts, dq_ptr, &blocked, &mut yielded); + (p.map(|(f, _)| f.nzb_ptr), fb, yielded) + }); + assert_eq!(picked_retry, Some(nzb_a)); + assert!(fallback_retry); + super::apply_pick_yield(nzb_a, fallback_retry, &yielded_retry); + assert!(!crate::liveorder::is_unpack_yielding(id_a)); + assert!( + crate::liveorder::unpack_pace_delay(id_a, b"PacedSeqA.part02.rar", 8 << 20) + > std::time::Duration::from_millis(50) + ); + + crate::liveorder::clear(id_a); + drop(opts_guard); + } + #[cfg(unix)] #[test] fn waiting_stragglers_are_hedged_after_floor_and_guarded_against_races() { diff --git a/rust/src/streamrepair.rs b/rust/src/streamrepair.rs index 8a22cff4c..c108ac6bc 100644 --- a/rust/src/streamrepair.rs +++ b/rust/src/streamrepair.rs @@ -10,6 +10,7 @@ use crate::dupefallback::NzbgetRsByteRange; use crate::releasename::lower as c_lower_bytes; use crate::status::NzbParStatus; +use zipfast::zipview; pub const MAX_DECOMPRESS_BYTES: i64 = 16 * 1024 * 1024 * 1024; diff --git a/rust/src/unpack.rs b/rust/src/unpack.rs index 96c272c51..e1693a611 100644 --- a/rust/src/unpack.rs +++ b/rust/src/unpack.rs @@ -3,6 +3,7 @@ pub use crate::postrepair::NzbgetRsUnpackMessageInfo; use crate::status::{NzbParStatus, UnpackStatus}; +use zipfast::zipview; #[inline] fn find_subslice(haystack: &[u8], needle: &[u8]) -> Option { diff --git a/site/build.py b/site/build.py index 321c0d4bb..cddb806a6 100644 --- a/site/build.py +++ b/site/build.py @@ -299,6 +299,34 @@ def parse_synthetic_controls(config_js: Path) -> dict[str, list[dict]]: } +def extract_config_js_option_refs(config_js: Path) -> list[str]: + """Extract option names referenced by LAYOUT cards and OPTION_REQUIRES in webui/config.js.""" + text = config_js.read_text(encoding="utf-8") + names: list[str] = [] + layout_m = re.search(r"var\s+LAYOUT\s*=\s*\{(.*?)\n\t\};", text, re.S) + if layout_m: + for arr_m in re.finditer(r"\b(?:options|advanced)\s*:\s*\[(.*?)\]", layout_m.group(1), re.S): + names.extend(re.findall(r"'([A-Za-z0-9_.]+)'", arr_m.group(1))) + req_m = re.search(r"var\s+OPTION_REQUIRES\s*=\s*\[(.*?)\n\t\];", text, re.S) + if req_m: + names.extend(re.findall(r"\b(?:option|name)\s*:\s*'([A-Za-z0-9_.]+)'", req_m.group(1))) + return names + + +def validate_config_js_options(config_js: Path, known: set[str]) -> None: + """Fail the build if webui/config.js exposes or wires an option missing from options.html.""" + missing: list[str] = [] + for raw_name in extract_config_js_option_refs(config_js): + generic = re.sub(r"(\D)\d+\.", r"\1N.", raw_name) + if generic not in known and raw_name not in missing: + missing.append(raw_name) + if missing: + raise SystemExit( + "webui/config.js references undocumented option(s) missing from rustyget.conf: " + + ", ".join(missing) + ) + + def parse_conf(path: Path, upstream: dict[str, str], index_js: Path | None = None, config_js: Path | None = None) -> list[dict]: """Parse rustyget.conf (plus WebUI preferences and synthetic controls) into documented option sections. @@ -359,7 +387,10 @@ def parse_conf(path: Path, upstream: dict[str, str], index_js: Path | None = Non if index_js is not None: webui_opts = [o for o in parse_webui_prefs(index_js) if o["name"] not in seen] if webui_opts: + seen.update(o["name"] for o in webui_opts) sections.insert(0, {"title": "Web interface", "options": webui_opts}) + if config_js is not None: + validate_config_js_options(config_js, seen) return sections diff --git a/site/check.py b/site/check.py index 24015b475..52fd59f36 100644 --- a/site/check.py +++ b/site/check.py @@ -103,6 +103,21 @@ def main() -> int: mode_slug = site_build.slugify(generic) if mode_slug not in option_ids: errors.append(f"options.html: missing OPTION_MODES anchor #{mode_slug} for {raw_name}") + layout_match = _re.search(r"var\s+LAYOUT\s*=\s*\{(.*?)\n\t\};", config_js_text, _re.S) + if layout_match: + for arr_match in _re.finditer(r"\b(?:options|advanced)\s*:\s*\[(.*?)\]", layout_match.group(1), _re.S): + for raw_name in _re.findall(r"'([A-Za-z0-9_.]+)'", arr_match.group(1)): + generic = _re.sub(r"(\D)\d+\.", r"\1N.", raw_name) + opt_slug = site_build.slugify(generic) + if opt_slug not in option_ids: + errors.append(f"options.html: missing LAYOUT anchor #{opt_slug} for {raw_name}") + requires_match = _re.search(r"var\s+OPTION_REQUIRES\s*=\s*\[(.*?)\n\t\];", config_js_text, _re.S) + if requires_match: + for raw_name in _re.findall(r"\b(?:option|name)\s*:\s*'([A-Za-z0-9_.]+)'", requires_match.group(1)): + generic = _re.sub(r"(\D)\d+\.", r"\1N.", raw_name) + opt_slug = site_build.slugify(generic) + if opt_slug not in option_ids: + errors.append(f"options.html: missing OPTION_REQUIRES anchor #{opt_slug} for {raw_name}") if "addRenamingControl" in config_js_text and "renaming" not in option_ids: errors.append("options.html: missing synthetic control anchor #renaming for Renaming") for name, scan in scans.items(): diff --git a/site/content/api.md b/site/content/api.md index 8af6304ae..20b8ce7de 100644 --- a/site/content/api.md +++ b/site/content/api.md @@ -119,7 +119,7 @@ The result: | Field | Meaning | |---|---| -| `UnpackPaced` | `true` while the download is held to its direct unpack's speed (option `UnpackPacing`). The web interface shows "paced to unpack (X MB/s)". | +| `UnpackPaced` | `true` while the download is held to its direct unpack's speed (option `UnpackPacing`). The web interface shows `paced to unpack (X MB/s)`. | | `UnpackPaceRate` | The speed it is held to, in bytes per second (0 when not paced). | | `UnpackPaceYield` | `true` while the held download's connections go to another download in the queue. | @@ -144,7 +144,7 @@ RustyGet also stores its findings as NZB parameters, which the API returns in `P | `DupeEase` | How easy the copy is to borrow into: `0` bare or split files, `1` stored archive, `2` compressed, `3` encrypted. | | `DupeCopyKind` | The copy's kind as the fleet classified it: `twin`, `borrowable`, `borrowable-encrypted`, `unknown`, or `unborrowable`. | | `DupeLocked` | `yes` on a copy whose archive headers are encrypted; it is locked while no password is at hand. | -| `DupeEncrypted7z` | `yes` on a copy the probe found to be an encrypted 7-Zip (password in the nzb), by its signature or its name. Failover never judges such a copy unrepairable. | +| `DupeEncrypted7z` | `yes` on a copy the probe found to be an encrypted 7-Zip (password in the nzb) via its signature or its name. Failover never judges such a copy unrepairable. | The `Health` field keeps NZBGet's meaning, so existing clients keep working: it counts every article not tried yet as good, which is why a held copy of a diff --git a/site/content/settings-processing.md b/site/content/settings-processing.md index 0ef3f4b5a..06c4698f1 100644 --- a/site/content/settings-processing.md +++ b/site/content/settings-processing.md @@ -35,7 +35,7 @@ Key options: [`ParCheck`](options.md#parcheck), [`ParRepair`](options.md#parrepa ## Unpack -Turn `Unpack` on when you want archive extraction. RustyGet extracts RAR, 7-Zip, ZIP, and tar archives itself, so it needs no external tools. `DirectUnpack` extracts RAR archives while articles arrive and pauses at a damaged volume until it's repaired; `UseTempUnpackDir` controls temporary extraction folders. `FeedThreads` sets how many threads decode a 7-Zip LZMA2 archive during live extraction. `UnpackSlots` sets how many extractions run at once (one by default, so each release finishes as soon as it can); an extraction waiting for a volume gives its slot back, and a downloading download goes before finished, paused or held ones. A finished download that waited long moves up, and a paused or held download's extraction gives way between volumes. `UnpackPacing` holds a download to its direct unpack's speed once the download leads by more than `UnpackPacingLag` (1536 MB by default); while another download in the queue can use the connections it gets them instead, and Downloads shows "paced to unpack (X MB/s)" on the held one. Turn it off to download at full speed and let the unpack catch up afterwards, if `InterDir` has room. +Turn `Unpack` on when you want archive extraction. RustyGet extracts RAR, 7-Zip, ZIP, and tar archives itself, so it needs no external tools. `DirectUnpack` extracts RAR archives while articles arrive and pauses at a damaged volume until it's repaired; `UseTempUnpackDir` controls temporary extraction folders. `FeedThreads` sets how many threads decode a 7-Zip LZMA2 archive during live extraction. `UnpackSlots` sets how many extractions run at once (one by default, so each release finishes as soon as it can); an extraction waiting for a volume gives its slot back, and a downloading download goes before finished, paused, or held ones. A finished download that waited long moves up, and a paused or held download's extraction gives way between volumes. `UnpackPacing` holds a download to its direct unpack's speed once the download leads by more than `UnpackPacingLag` (1536 MB by default); while another download in the queue can use the connections it gets them instead, and Downloads shows "paced to unpack (X MB/s)" on the held one. Turn it off to download at full speed and let the unpack catch up afterwards, if `InterDir` has room. `UnpackCleanupDisk` removes archive files after successful extraction. Choose it according to what you want the completed folder to retain. `UnpackIgnoreExt` lists nonstandard RAR extensions, such as `.cbr`, that should keep their names during RAR renaming. It also suppresses the failure for finding only nonstandard RAR archives with those extensions. Recognized `.rar` and `.7z` archives still follow normal extraction. `UnpackPassFile` supplies a password-list file when needed.