diff --git a/src/freedesktop.rs b/src/freedesktop.rs index 625c8e4..a8bca87 100644 --- a/src/freedesktop.rs +++ b/src/freedesktop.rs @@ -896,7 +896,7 @@ mod tests { let names: Vec = (0..files_per_batch).map(|i| format!("{}#{}", file_name_prefix, i).into()).collect(); for _ in 0..batches { for path in &names { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } // eprintln!("Deleting {:?}", names); let result = delete_all_using_system_program(&names); @@ -946,7 +946,7 @@ mod tests { let symlink_names: Vec = names.iter().map(|name| format!("{:?}-symlink", name).into()).collect(); // Test file symbolic link and directory symbolic link - File::create(&names[0]).unwrap(); + File::create_new(&names[0]).unwrap(); std::fs::create_dir(&names[1]).unwrap(); for (i, (name, symlink)) in names.iter().zip(&symlink_names).enumerate() { diff --git a/src/macos.rs b/src/macos.rs index 43c3009..05eacf3 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -153,7 +153,7 @@ mod tests { trash_ctx.set_delete_method(DeleteMethod::NsFileManager); let path = get_unique_name(); - File::create(&path).unwrap(); + File::create_new(&path).unwrap(); trash_ctx.delete(&path).unwrap(); assert!(File::open(&path).is_err()); } diff --git a/src/tests.rs b/src/tests.rs index 993bad1..41ad08a 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -52,7 +52,7 @@ mod os_limited { let names: Vec = (0..files_per_batch).map(|i| format!("{}#{}", file_name_prefix, i).into()).collect(); for _ in 0..batches { for path in names.iter() { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } trash::delete_all(&names).unwrap(); } @@ -104,7 +104,7 @@ mod os_limited { let mut name = OsStr::new(&get_unique_name()).to_os_string().into_encoded_bytes(); name.push(168); let name = OsString::from_vec(name); - File::create(&name).unwrap(); + File::create_new(&name).unwrap(); // Delete, list, and remove file with an invalid UTF8 name // Listing items is already exhaustively checked above, so this test is mainly concerned @@ -136,7 +136,7 @@ mod os_limited { let names: Vec<_> = (0..files_per_batch).map(|i| format!("{}#{}", file_name_prefix, i)).collect(); for _ in 0..batches { for path in names.iter() { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } trash::delete_all(&names).unwrap(); } @@ -165,7 +165,7 @@ mod os_limited { let file_count: usize = 3; let names: Vec<_> = (0..file_count).map(|i| format!("{}#{}", file_name_prefix, i)).collect(); for path in names.iter() { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } trash::delete_all(&names).unwrap(); @@ -207,11 +207,11 @@ mod os_limited { let collision_remaining = file_count - 1; let names: Vec<_> = (0..file_count).map(|i| format!("{}#{}", file_name_prefix, i)).collect(); for path in names.iter() { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } trash::delete_all(&names).unwrap(); for path in names.iter().skip(file_count - collision_remaining) { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } let mut targets: Vec<_> = trash::os_limited::list() .unwrap() @@ -264,12 +264,12 @@ mod os_limited { let file_count: usize = 4; let names: Vec<_> = (0..file_count).map(|i| format!("{}#{}", file_name_prefix, i)).collect(); for path in names.iter() { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } trash::delete_all(&names).unwrap(); let twin_name = &names[1]; - File::create(twin_name).unwrap(); + File::create_new(twin_name).unwrap(); trash::delete(twin_name).unwrap(); let mut targets: Vec<_> = trash::os_limited::list() diff --git a/tests/trash.rs b/tests/trash.rs index 936c7fc..70f6400 100644 --- a/tests/trash.rs +++ b/tests/trash.rs @@ -34,7 +34,7 @@ fn test_delete_file() { trace!("Started test_delete_file"); let path = get_unique_name(); - File::create(&path).unwrap(); + File::create_new(&path).unwrap(); delete(&path).unwrap(); assert!(File::open(&path).is_err()); @@ -49,7 +49,7 @@ fn test_delete_folder() { let path = PathBuf::from(get_unique_name()); create_dir(&path).unwrap(); - File::create(path.join("file_in_folder")).unwrap(); + File::create_new(path.join("file_in_folder")).unwrap(); assert!(path.exists()); delete(&path).unwrap(); @@ -66,7 +66,7 @@ fn test_delete_all() { let paths: Vec<_> = (0..count).map(|i| format!("test_file_to_delete_{i}")).collect(); for path in paths.iter() { - File::create(path).unwrap(); + File::create_new(path).unwrap(); } delete_all(&paths).unwrap(); @@ -94,7 +94,7 @@ mod unix { init_logging(); trace!("Started test_delete_symlink"); let target_path = get_unique_name(); - File::create(&target_path).unwrap(); + File::create_new(&target_path).unwrap(); let link_path = "test_link_to_delete"; symlink(&target_path, link_path).unwrap(); @@ -112,7 +112,7 @@ mod unix { init_logging(); trace!("Started test_delete_symlink_in_folder"); let target_path = "test_link_target_for_delete_from_folder"; - File::create(target_path).unwrap(); + File::create_new(target_path).unwrap(); let folder = Path::new("test_parent_folder_for_link_to_delete"); create_dir(folder).unwrap(); @@ -134,7 +134,7 @@ mod unix { fn create_remove_single_file() { // Let's create and remove a single file let name = get_unique_name(); - File::create(&name).unwrap(); + File::create_new(&name).unwrap(); trash::delete(&name).unwrap(); assert!(File::open(&name).is_err()); } @@ -144,7 +144,7 @@ fn create_remove_single_file() { #[serial] fn create_remove_single_file_invalid_utf8() { let name = unsafe { OsStr::from_encoded_bytes_unchecked(&[168]) }; - File::create(name).unwrap(); + File::create_new(name).unwrap(); trash::delete(name).unwrap(); } @@ -155,8 +155,8 @@ fn recursive_file_deletion() { let dir2 = parent_dir.join("dir2"); std::fs::create_dir_all(&dir1).unwrap(); std::fs::create_dir_all(&dir2).unwrap(); - File::create(dir1.join("same-name")).unwrap(); - File::create(dir2.join("same-name")).unwrap(); + File::create_new(dir1.join("same-name")).unwrap(); + File::create_new(dir2.join("same-name")).unwrap(); trash::delete(parent_dir).unwrap(); assert!(!parent_dir.exists()); @@ -169,7 +169,7 @@ fn recursive_file_with_content_deletion() { let dir2 = parent_dir.join("dir2"); std::fs::create_dir_all(&dir1).unwrap(); std::fs::create_dir_all(&dir2).unwrap(); - File::create(dir1.join("same-name")).unwrap(); + File::create_new(dir1.join("same-name")).unwrap(); std::fs::write(dir2.join("same-name"), b"some content").unwrap(); trash::delete(parent_dir).unwrap();