Skip to content

Commit bc78d81

Browse files
rcorreku1ik
authored andcommitted
Remove output file if conversion fails.
Fixes #97. This prevents `agg` from leaving an empty file behind if the conversion fails.
1 parent e9e4945 commit bc78d81

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,11 @@ fn main() -> Result<()> {
182182

183183
let input = BufReader::new(reader(&cli.input_filename_or_url)?);
184184
let mut output = File::create(&cli.output_filename)?;
185-
agg::run(input, &mut output, config)
185+
match agg::run(input, &mut output, config) {
186+
Ok(ok) => Ok(ok),
187+
Err(err) => {
188+
std::fs::remove_file(cli.output_filename)?;
189+
Err(err)
190+
}
191+
}
186192
}

0 commit comments

Comments
 (0)