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 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 02:29:19 +00:00
parent 65ca481525
commit 19f77a21d9
2 changed files with 12 additions and 1 deletions

View File

@@ -2032,7 +2032,12 @@ async fn policy_for(ctx: &Ctx, id: &str, feed_cfg: &config::Feed) -> Result<Poli
}
fn merge_policy(subs: &[db::Sub], feed_cfg: &config::Feed, global: usize) -> Policy {
let cap = |n: Option<usize>| 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<usize>| 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"], &[]));