copy & remove instead of persist/rename
parent
d46f449e4b
commit
7def06e153
|
@ -18,13 +18,13 @@ use futures_util::TryStreamExt;
|
||||||
use log::{debug, info, trace};
|
use log::{debug, info, trace};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use std::time::UNIX_EPOCH;
|
use std::time::UNIX_EPOCH;
|
||||||
|
use std::{collections::HashMap, io};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
#[cfg(feature = "desktop")]
|
#[cfg(feature = "desktop")]
|
||||||
|
@ -227,8 +227,13 @@ pub async fn put_object(
|
||||||
|
|
||||||
let final_path = state.upend.vault_path.join(&final_name);
|
let final_path = state.upend.vault_path.join(&final_name);
|
||||||
|
|
||||||
file.persist(&final_path)
|
let (_, tmp_path) = file.keep().map_err(ErrorInternalServerError)?;
|
||||||
.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 metadata = fs::metadata(&final_path)?;
|
||||||
let size = metadata.len() as i64;
|
let size = metadata.len() as i64;
|
||||||
|
|
Loading…
Reference in New Issue