From 19f77a21d91f949493a0d5fbdf0ac25b543334d5 Mon Sep 17 00:00:00 2001 From: rays Date: Fri, 9 Oct 2026 02:29:19 +0000 Subject: [PATCH] Take 0 as every item wherever the download limit is set (#166) The feed settings dialog says 0 means every episode, the whole back catalogue, and as the server's default it does. But merge_policy's cap() made only the server-wide 0 unlimited: a 0 set on a feed, or on one person's subscription, became a budget of 0, hold_back held every file, and nothing downloaded. Now 0 is unlimited at every level, as the dialog has always said. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + src/main.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a18068..f9e1cb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- A feed set to download 0 of its newest items downloads all of them, the whole back catalogue, as the server's 0 does; it downloaded nothing. - The feed list loads faster: it counts the items and files of your own feeds, not of every feed on the server. - Downloading or deleting a file the server no longer has answers "not found" instead of a server error. - A feed's page in the Directory, and subscribing from it, no longer wait while the whole Directory is put together to check that the one feed is in it. diff --git a/src/main.rs b/src/main.rs index 67dd353..29ca7ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2032,7 +2032,12 @@ async fn policy_for(ctx: &Ctx, id: &str, feed_cfg: &config::Feed) -> Result Policy { - let cap = |n: Option| n.unwrap_or(if global == 0 { usize::MAX } else { global }); + // 0 is every item, the whole back catalogue, wherever it is set: the server's default, a + // feed's or one person's. Only the server's was; a feed set to 0 downloaded nothing (#166). + let cap = |n: Option| match n.unwrap_or(global) { + 0 => usize::MAX, + n => n, + }; if subs.is_empty() { return Policy { @@ -2409,6 +2414,11 @@ mod tests { assert!(!p.wanted(&["python"], &[])); assert_eq!(p.budget, 9); + // 0 is the whole back catalogue, set for the server, for the feed or by one person (#166). + assert_eq!(merge_policy(&[], &feed(), 0).budget, usize::MAX); + assert_eq!(merge_policy(&[], &config::Feed { max_new_per_check: Some(0), ..feed() }, 3).budget, usize::MAX); + assert_eq!(merge_policy(&[sub(None, None, Some(0)), sub(None, None, Some(2))], &feed(), 3).budget, usize::MAX); + // One person taking everything removes the filter for the shared copy. let p = merge_policy(&[sub(Some(&["rust"]), None, None), sub(Some(&[]), None, None)], &feed(), 3); assert!(p.wanted(&["python"], &[]));