|
16 | 16 |
|
17 | 17 | use lcc_catalog::{Op, Photo, Source}; |
18 | 18 | use serde_json::json; |
| 19 | +use std::path::Path; |
19 | 20 |
|
20 | 21 | use crate::{LibrarySource, Session, filter_chips}; |
21 | 22 |
|
@@ -841,3 +842,29 @@ fn a_destination_without_write_permission_reports_an_error_and_keeps_everything( |
841 | 842 | } |
842 | 843 | std::fs::set_permissions(dir.0.join("ro"), std::fs::Permissions::from_mode(0o755)).unwrap(); |
843 | 844 | } |
| 845 | + |
| 846 | +#[test] |
| 847 | +fn a_date_folder_inside_the_library_can_be_renamed_but_the_librarys_own_folders_cannot() { |
| 848 | + let dir = Scratch::new("in-library"); |
| 849 | + let lib = dir.0.join("lib"); |
| 850 | + let mut s = Session::new(); |
| 851 | + s.open_library(&lib, false).unwrap(); |
| 852 | + let day = lib.join("Originals").join("2026-10-16"); |
| 853 | + std::fs::create_dir_all(&day).unwrap(); |
| 854 | + add(&mut s, &day.join("a.jpg").to_string_lossy()); |
| 855 | + let day = day.to_string_lossy().to_string(); |
| 856 | + s.execute("folder.rename", &json!({"path": day, "name": "Beach"})).unwrap(); |
| 857 | + assert!(lib.join("Originals/Beach").is_dir(), "the imported date folder is renamed"); |
| 858 | + assert!(!Path::new(&day).exists()); |
| 859 | + s.execute("edit.undo", &json!({})).unwrap(); |
| 860 | + assert!(Path::new(&day).is_dir(), "undo names it back"); |
| 861 | + for own in ["Originals", "thumbs"] { |
| 862 | + std::fs::create_dir_all(lib.join(own)).unwrap(); |
| 863 | + let path = lib.join(own).to_string_lossy().to_string(); |
| 864 | + assert!(s.execute("folder.rename", &json!({"path": path, "name": "x"})).is_err(), "{own} stays put"); |
| 865 | + } |
| 866 | + assert!(s.execute("folder.rename", &json!({"path": lib.to_string_lossy(), "name": "x"})).is_err(), "and so does the library"); |
| 867 | + let alias = lib.join("Originals").join("..").join("Originals").to_string_lossy().to_string(); |
| 868 | + assert!(s.execute("folder.rename", &json!({"path": alias, "name": "x"})).is_err(), "even named through '..'"); |
| 869 | + assert!(lib.join("Originals").is_dir()); |
| 870 | +} |
0 commit comments