diff options
author | metamuffin <metamuffin@disroot.org> | 2023-09-06 15:34:36 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-09-06 15:34:36 +0200 |
commit | 93397112ce9d942d2da791d99640fabb7f7e31a9 (patch) | |
tree | 0483e25fd8c9f951c3d7699cd222f810ce9c42d3 | |
parent | 185ac499ba46ff02c2ceee48ef2b467c469bc783 (diff) | |
download | jellything-93397112ce9d942d2da791d99640fabb7f7e31a9.tar jellything-93397112ce9d942d2da791d99640fabb7f7e31a9.tar.bz2 jellything-93397112ce9d942d2da791d99640fabb7f7e31a9.tar.zst |
dont write cover if it is already saved
-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() |