fix(connect): ignore directory link-count churn (#6658)

This commit is contained in:
Zhengchao An
2026-08-26 18:50:41 +08:00
committed by GitHub
parent 286626c1bd
commit 9ea5cd59ca
2 changed files with 5 additions and 2 deletions
+2 -2
View File
@@ -1083,10 +1083,10 @@ fn unix_regular_file_is_secure(owner: u32, mode: u32, links: u64, process: u32)
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[allow(dead_code)] // Used by the crate-private stopped-server reader. #[allow(dead_code)] // Used by the crate-private stopped-server reader.
fn file_identity(file: &fs::File) -> Result<(u64, u64, u64), InventoryError> { fn file_identity(file: &fs::File) -> Result<(u64, u64), InventoryError> {
use std::os::unix::fs::MetadataExt as _; use std::os::unix::fs::MetadataExt as _;
let metadata = file.metadata().map_err(|_| InventoryError::StateIo)?; let metadata = file.metadata().map_err(|_| InventoryError::StateIo)?;
Ok((metadata.dev(), metadata.ino(), metadata.nlink())) Ok((metadata.dev(), metadata.ino()))
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
+3
View File
@@ -607,6 +607,9 @@ mod tests {
_lock: lock, _lock: lock,
}; };
// Directory link counts change when unrelated sibling directories
// come and go; that must not look like an anchored path replacement.
std::fs::create_dir(temp.path().join("unrelated-sibling")).expect("unrelated sibling directory");
drop(runtime); drop(runtime);
assert!(matches!(store.try_runtime_lock(), Err(InventoryError::AlreadyRunning))); assert!(matches!(store.try_runtime_lock(), Err(InventoryError::AlreadyRunning)));
release.send(()).expect("release inventory task"); release.send(()).expect("release inventory task");