Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
9-5 job or 9-5 job
Browse files Browse the repository at this point in the history
  • Loading branch information
raisfeld-ori committed May 1, 2024
1 parent 39c3313 commit 5bf1d2b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src-tauri/src/fs/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5bf1d2b

Please sign in to comment.