diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/actions.rs | 6 | ||||
| -rw-r--r-- | src/main.rs | 2 | ||||
| -rw-r--r-- | src/utils.rs | 9 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/actions.rs b/src/actions.rs index c3ed2ac..c943769 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -66,11 +66,9 @@ pub fn update_subscription(sub: &mut Subscription) -> Result<()> { let resp = reqwest::get(&sub.url)?; let podcast = Podcast::from(Channel::read_from(BufReader::new(resp))?); - let mut filename = String::from(podcast.title()); - filename.push_str(".xml"); - let mut podcast_rss_path = get_xml_dir()?; - podcast_rss_path.push(&filename); + podcast_rss_path.push(podcast.title()); + podcast_rss_path.set_extension("xml"); let file = File::create(&podcast_rss_path)?; (*podcast).write_to(BufWriter::new(file))?; diff --git a/src/main.rs b/src/main.rs index bdf913a..640e480 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ mod errors { use self::structs::*; use errors::Result; -const VERSION: &str = "0.10.0"; +const VERSION: &str = "0.10.1"; fn main() -> Result<()> { utils::create_directories()?; diff --git a/src/utils.rs b/src/utils.rs index e00df98..bb96909 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -13,8 +13,11 @@ const UNSUBSCRIBE_NOTE: &str = "Note: this does NOT delete any downloaded podcas pub fn trim_extension(filename: &str) -> Option<String> { let name = String::from(filename); - let index = name.rfind('.')?; - Some(String::from(&name[0..index])) + if name.contains(".") { + name.rfind('.').map(|index| String::from(&name[0..index])) + } else { + Some(name) + } } pub fn find_extension(input: &str) -> Option<String> { @@ -166,6 +169,6 @@ mod tests { #[test] fn test_trim_extension_invalid() { - assert_eq!(trim_extension("test"), None) + assert_eq!(trim_extension("test"), Some("test".into())) } } |
