diff --git a/src-tauri/src/fs/fs.rs b/src-tauri/src/fs/fs.rs index 65e10a7..61f3f2d 100644 --- a/src-tauri/src/fs/fs.rs +++ b/src-tauri/src/fs/fs.rs @@ -48,12 +48,13 @@ pub fn upload_file(name: &str, password: &str, file_path: String) -> Result<(), let existing_file_names: Vec<&String> = unsafe{FS.current_dir.files.iter()} .map(|file|{return file.name();}).collect(); fn unique_file_name(name: String, all_names: Vec<&String>, num: i32) -> String{ - if (all_names.contains(&&name)){ + let num_str = num.to_string().as_str(); + if all_names.contains(&&name + &num_str){ let num = num + 1; - let name = name + num.to_string().as_str(); return unique_file_name(name, all_names, num); } - else {return name;} + else if num == 0 {return name;} + else {return name + num_str;} } let num = 1; let file_name = unique_file_name(file_name, existing_file_names, num);