diff --git a/src/util.rs b/src/util.rs index 063ff0aa..d0c04e4d 100644 --- a/src/util.rs +++ b/src/util.rs @@ -14,6 +14,7 @@ use self::serde_json::Value as JsonValue; use std::collections::HashMap; use self::url::Url; use std::io::Read; +use std::path::Path; use std::fs::File; use std::io::prelude::*; @@ -214,6 +215,12 @@ pub fn dw_media(base: &Url, url: &str, thumb: bool, dest: Option<&str>, w: i32, Some(d) => String::from(d) + &media }; + let pathname = fname.clone(); + let p = Path::new(&pathname); + if p.is_file() { + return Ok(fname); + } + let mut file = File::create(&fname)?; let buffer = get_media(url.as_str())?; file.write_all(&buffer)?;