Skip to content

Commit

Permalink
avoid the copy when file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
huangcheng committed Nov 28, 2023
1 parent 25e859a commit 690def5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/handlers/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ pub async fn upload(file: &TempFile<'_>, path: &PathBuf) -> Result<String, Servi

let target = path.join(result.clone());

if target.exists() {
return Ok(result);
}

fs::copy(tmp_file, &target).map_err(|e| {
error!("Failed to copy file: {}", e);

Expand Down

0 comments on commit 690def5

Please sign in to comment.