Skip to content

Commit

Permalink
fix: auto delete half-uploaded files (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Nov 3, 2023
1 parent 70300b1 commit 8b4cab1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ impl Server {

futures::pin_mut!(body_reader);

io::copy(&mut body_reader, &mut file).await?;
let ret = io::copy(&mut body_reader, &mut file).await;
if ret.is_err() {
tokio::fs::remove_file(&path).await?;

ret?;
}

*res.status_mut() = StatusCode::CREATED;
Ok(())
Expand Down

0 comments on commit 8b4cab1

Please sign in to comment.