From 83c0b819bc4378d5ef04faca34214db943d087cd Mon Sep 17 00:00:00 2001 From: overtrue Date: Mon, 17 Aug 2026 02:03:06 +0800 Subject: [PATCH] fix(scanner): canonicalize temp_dir for drive field assertion on macOS On macOS, /var is a symlink to /private/var. The scanner's local_disk.path() returns the canonicalized path, but tempfile::tempdir() returns the non-canonical /var/... path. This caused the drive field assertion in test_scan_folder_corrupt_xl_meta_stops_erasure_data_dir_descent to fail with a path mismatch. Fix by canonicalizing temp_dir only for the drive field comparison, while keeping the non-canonical path for metadata_path and failed_objects which use the original directory walk paths. --- crates/scanner/src/scanner_folder.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/scanner/src/scanner_folder.rs b/crates/scanner/src/scanner_folder.rs index 7e353bf75..25f1e758d 100644 --- a/crates/scanner/src/scanner_folder.rs +++ b/crates/scanner/src/scanner_folder.rs @@ -4621,6 +4621,8 @@ mod tests { let _subscriber_guard = tracing::subscriber::set_default(subscriber); let (mut scanner, temp_dir) = build_test_scanner().await; + // Canonicalize for the "drive" field comparison (scanner resolves symlinks). + let canonical_temp_dir = std::fs::canonicalize(&temp_dir).unwrap_or_else(|_| temp_dir.clone()); let _guard = TestGuard::new(60, 100, &mut scanner, temp_dir.clone()); let object_dir = temp_dir.join("bucket").join("object"); @@ -4689,7 +4691,7 @@ mod tests { let fields = &events[0]["fields"]; assert_eq!(fields["component"], LOG_COMPONENT_SCANNER); assert_eq!(fields["subsystem"], LOG_SUBSYSTEM_FOLDER); - assert_eq!(fields["drive"], temp_dir.to_string_lossy().as_ref()); + assert_eq!(fields["drive"], canonical_temp_dir.to_string_lossy().as_ref()); assert_eq!(fields["bucket"], "bucket"); assert_eq!(fields["object"], "object"); assert_eq!(fields["metadata_path"], metadata_path.to_string_lossy().as_ref());