diff --git a/src/routes.rs b/src/routes.rs index 990ee0e..43a3dab 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -18,13 +18,13 @@ use futures_util::TryStreamExt; use log::{debug, info, trace}; use serde::Deserialize; use serde_json::json; -use std::collections::HashMap; use std::convert::TryFrom; use std::fs; use std::io::Write; use std::path::PathBuf; use std::sync::{Arc, RwLock}; use std::time::UNIX_EPOCH; +use std::{collections::HashMap, io}; use tempfile::NamedTempFile; #[cfg(feature = "desktop")] @@ -227,8 +227,13 @@ pub async fn put_object( let final_path = state.upend.vault_path.join(&final_name); - file.persist(&final_path) - .map_err(ErrorInternalServerError)?; + let (_, tmp_path) = file.keep().map_err(ErrorInternalServerError)?; + let final_path = web::block::<_, _, io::Error>(move || { + fs::copy(&tmp_path, &final_path)?; + fs::remove_file(tmp_path)?; + Ok(final_path) + }) + .await?; let metadata = fs::metadata(&final_path)?; let size = metadata.len() as i64;