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:
@@ -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.
|
||||
|
||||
12
src/main.rs
12
src/main.rs
@@ -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"], &[]));
|
||||
|
||||
Reference in New Issue
Block a user