diff options
-rw-r--r-- | import/src/main.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/import/src/main.rs b/import/src/main.rs index 3bbd3a2..febdbe9 100644 --- a/import/src/main.rs +++ b/import/src/main.rs @@ -23,7 +23,7 @@ use rand::random; use std::{ collections::BTreeMap, fs::{remove_file, File}, - io::{stdin, Write}, + io::{stdin, BufReader, Write}, path::PathBuf, process::exit, }; @@ -204,7 +204,7 @@ fn main() -> anyhow::Result<()> { if let Some(input_path) = &input { file_meta = Some({ - let input = File::open(&input_path).unwrap(); + let input = BufReader::new(File::open(&input_path).unwrap()); let mut input = EbmlReader::new(input); import_metadata(&mut input)? }); @@ -266,8 +266,10 @@ fn main() -> anyhow::Result<()> { } } )); - let mut f = File::create(&pu)?; - f.write_all(&data)?; + if !pu.exists() { + let mut f = File::create(&pu)?; + f.write_all(&data)?; + } Ok::<_, anyhow::Error>(pu) }) .transpose() |