From 9d9a6dfddbb2cfd462c4441a6e45541f9ae3ded2 Mon Sep 17 00:00:00 2001 From: huzibaca Date: Fri, 8 Nov 2024 23:42:00 +0800 Subject: [PATCH] chore: update --- src-tauri/src/feat.rs | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src-tauri/src/feat.rs b/src-tauri/src/feat.rs index f5f954c..c28108f 100644 --- a/src-tauri/src/feat.rs +++ b/src-tauri/src/feat.rs @@ -404,31 +404,23 @@ pub async fn test_delay(url: String) -> Result { } pub async fn create_backup_and_upload_webdav() -> Result<()> { - if let Err(err) = async { - let (file_name, temp_file_path) = backup::create_backup().map_err(|err| { - log::error!(target: "app", "Failed to create backup: {:#?}", err); - err - })?; + let (file_name, temp_file_path) = backup::create_backup().map_err(|err| { + log::error!(target: "app", "Failed to create backup: {:#?}", err); + err + })?; - backup::WebDavClient::global() - .upload(temp_file_path.clone(), file_name) - .await - .map_err(|err| { - log::error!(target: "app", "Failed to upload to WebDAV: {:#?}", err); - err - })?; - - std::fs::remove_file(&temp_file_path).map_err(|err| { - log::warn!(target: "app", "Failed to remove temp file: {:#?}", err); - err - })?; - - Ok(()) - } - .await + if let Err(err) = backup::WebDavClient::global() + .upload(temp_file_path.clone(), file_name) + .await { + log::error!(target: "app", "Failed to upload to WebDAV: {:#?}", err); return Err(err); } + + if let Err(err) = std::fs::remove_file(&temp_file_path) { + log::warn!(target: "app", "Failed to remove temp file: {:#?}", err); + } + Ok(()) }