fix: auto delete half-uploaded files (#280)
This commit is contained in:
parent
70300b133c
commit
8b4cab1e69
1 changed files with 6 additions and 1 deletions
|
@ -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(())
|
||||
|
|
Loading…
Reference in a new issue