Skip to content

Commit

Permalink
Fix subscribe being broken if no existing subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jaremn committed Jul 19, 2020
1 parent 0de333b commit dba9cf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "podcast"
edition = "2018"
version = "0.17.4"
version = "0.17.5"
authors = ["Nathan Jaremko <njaremko@gmail.com>"]
description = "A command line podcast manager"
license = "GPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use futures::future;
use std::io::Write;
use std::thread;

const VERSION: &str = "0.17.4";
const VERSION: &str = "0.17.5";

fn main() -> Result<()> {
// Same number of threads as there are CPU cores.
Expand Down
8 changes: 7 additions & 1 deletion src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ impl State {

pub async fn subscribe(&mut self, url: &str) -> Result<()> {
// Make a bloom filter and populate it with subscription titles
let mut bloom_filter = bloom::BloomFilter::with_rate(0.1, self.subscriptions.len() as u32);
let existing_subscriptions = if self.subscriptions.is_empty() {
10
} else {
self.subscriptions.len()
};

let mut bloom_filter = bloom::BloomFilter::with_rate(0.1, existing_subscriptions as u32);
for sub in &self.subscriptions {
bloom_filter.insert(&sub.title);
}
Expand Down

0 comments on commit dba9cf9

Please sign in to comment.