Don't download media files if exist
This commit is contained in:
parent
61295100ee
commit
834dd48444
1 changed files with 7 additions and 0 deletions
|
@ -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)?;
|
||||
|
|
Loading…
Reference in a new issue