mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-30 13:07:43 -06:00
Issue #989: odd_folders_never_fail_the_check skips its non-UTF-8 names where the file system refuses them (item 3, one of eleven)
APFS refuses names that are not valid UTF-8 (EILSEQ, os error 92), so the test's create_dir_all(...).unwrap() panicked on macOS. The test now probes once with a \xff folder; where that fails, the non-UTF-8 folder case and the non-UTF-8 entry are skipped and the catalog-folder and symlink cases still run on a plain-named folder. Where the probe succeeds (Linux, FreeBSD) the test is unchanged. Run on macOS (case-insensitive APFS, rustc 1.99.0): the five tests in tests_lightroom_folder pass, cargo fmt is clean, and clippy over lightcraft-engine with --all-targets is clean. The ten sidecar tests of item 3 are not touched. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
76b5377868
commit
8760dc4a41
@@ -155,13 +155,22 @@ fn odd_folders_never_fail_the_check() {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let bad = root.join(std::ffi::OsStr::from_bytes(b"caf\xe9 Previews.lrdata"));
|
||||
std::fs::create_dir_all(&bad).unwrap();
|
||||
std::fs::write(root.join("Cat.lrcat"), b"x").unwrap();
|
||||
assert_eq!(lightroom_catalog_at(&bad), Some(LightroomPlace { catalog: Some(root.join("Cat.lrcat")) }), "non-UTF-8 name");
|
||||
let lr = root.join(std::ffi::OsStr::from_bytes(b"\xff\xfe"));
|
||||
// APFS (macOS) refuses names that are not valid UTF-8 (EILSEQ): there the non-UTF-8 cases are skipped and
|
||||
// the symlink cases below still run on a plain-named catalog folder
|
||||
let probe = root.join(std::ffi::OsStr::from_bytes(b"\xff"));
|
||||
let utf8_only = std::fs::create_dir(&probe).is_err();
|
||||
let _ = std::fs::remove_dir(&probe);
|
||||
if !utf8_only {
|
||||
let bad = root.join(std::ffi::OsStr::from_bytes(b"caf\xe9 Previews.lrdata"));
|
||||
std::fs::create_dir_all(&bad).unwrap();
|
||||
std::fs::write(root.join("Cat.lrcat"), b"x").unwrap();
|
||||
assert_eq!(lightroom_catalog_at(&bad), Some(LightroomPlace { catalog: Some(root.join("Cat.lrcat")) }), "non-UTF-8 name");
|
||||
}
|
||||
let lr = root.join(if utf8_only { std::ffi::OsStr::new("lr") } else { std::ffi::OsStr::from_bytes(b"\xff\xfe") });
|
||||
std::fs::create_dir_all(&lr).unwrap();
|
||||
std::fs::write(lr.join(std::ffi::OsStr::from_bytes(b"\xff.lrcat")), b"x").unwrap();
|
||||
if !utf8_only {
|
||||
std::fs::write(lr.join(std::ffi::OsStr::from_bytes(b"\xff.lrcat")), b"x").unwrap();
|
||||
}
|
||||
std::fs::write(lr.join("b.lrcat"), b"x").unwrap();
|
||||
assert_eq!(lightroom_catalog_at(&lr), Some(LightroomPlace { catalog: Some(lr.join("b.lrcat")) }), "non-UTF-8 entries skipped");
|
||||
// a symlink to a catalog folder is one too; a dangling one is not
|
||||
|
||||
Reference in New Issue
Block a user