From cf82e9e892bec76dc1b57772368f39fac1341ea5 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sat, 16 Jul 2022 22:02:21 -0700 Subject: [PATCH] use path bufs for copying files --- src-tauri/src/file_helpers.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/file_helpers.rs b/src-tauri/src/file_helpers.rs index 6493e5c..0f0a0d7 100644 --- a/src-tauri/src/file_helpers.rs +++ b/src-tauri/src/file_helpers.rs @@ -45,6 +45,7 @@ pub fn are_files_identical(path1: &str, path2: &str) -> bool { pub fn copy_file(path: String, new_path: String) -> bool { let filename = &path.split('/').last().unwrap(); let mut new_path_buf = std::path::PathBuf::from(&new_path); + let path_buf = std::path::PathBuf::from(&path); // If the new path doesn't exist, create it. if !dir_exists(new_path_buf.pop().to_string().as_str()) { @@ -52,7 +53,7 @@ pub fn copy_file(path: String, new_path: String) -> bool { } // Copy old to new - match std::fs::copy(&path, format!("{}/{}", new_path, filename)) { + match std::fs::copy(&path_buf, format!("{}/{}", new_path, filename)) { Ok(_) => true, Err(e) => { println!("Failed to copy file: {}", e); @@ -64,6 +65,7 @@ pub fn copy_file(path: String, new_path: String) -> bool { #[tauri::command] pub fn copy_file_with_new_name(path: String, new_path: String, new_name: String) -> bool { let mut new_path_buf = std::path::PathBuf::from(&new_path); + let path_buf = std::path::PathBuf::from(&path); // If the new path doesn't exist, create it. if !dir_exists(new_path_buf.pop().to_string().as_str()) { @@ -77,7 +79,7 @@ pub fn copy_file_with_new_name(path: String, new_path: String, new_name: String) } // Copy old to new - match std::fs::copy(&path, format!("{}/{}", new_path, new_name)) { + match std::fs::copy(&path_buf, format!("{}/{}", new_path, new_name)) { Ok(_) => true, Err(e) => { println!("Failed to copy file: {}", e);