LRC-LIB-FOLDERS: the relative-path test pins the absolute spelling; docs name the engine refusal

This commit is contained in:
Nathaniel Ledford
2026-10-28 17:07:51 -04:00
parent d0a64f8e30
commit 0311abdff6
2 changed files with 9 additions and 3 deletions
+8 -2
View File
@@ -601,7 +601,9 @@ fn standard_places(home: &Path) -> Vec<std::path::PathBuf> {
}
/// Whether `from` is, on disk, one of `places`, however it is spelled (a firmlink or bind mount
/// reaches the same folder under another path). A link to a place is not the place.
/// reaches the same folder under another path). A link to a place is not the place, but what a
/// link in a place points to is the place too (the places are read through their links), since
/// renaming it would break the place.
#[cfg(unix)]
fn is_one_of(from: &str, places: &[std::path::PathBuf]) -> bool {
use std::os::unix::fs::MetadataExt;
@@ -684,7 +686,11 @@ mod tests {
// the commands act on the process's working folder, so a relative path names the real place
let cwd = std::env::current_dir().expect("working folder");
let relative = pathdiff(&home.join("Pictures"), &cwd);
assert!(refuse_protected_place_in("folder.rename", &relative, Some(&home)).is_err(), "{relative}");
if !Path::new(&relative).is_absolute() {
// what the commands will see: the working folder's spelling of the same place
assert!(super::named_places(&relative).iter().any(|p| is_protected_place(p, &home)), "{relative}");
assert!(refuse_protected_place_in("folder.rename", &relative, Some(&home)).is_err(), "{relative}");
}
let _ = std::fs::remove_dir_all(&dir);
}