Share native checkpoint command bindings and output probes
This commit is contained in:
1 parent
8aa079ec25
commit
373204a8d8
4 files changed
+167
-50
No files matched your search
@@ -193,6 +193,45 @@ impl HostPreparation {
|
||||
}
|
||||
}
|
||||
|
||||
/// Compare two outputs with the same protected paths in one live scan.
|
||||
pub(crate) fn either_aliases_any<'a>(
|
||||
&mut self,
|
||||
outputs: [&Path; 2],
|
||||
candidates: impl Iterator<Item = &'a Path> + Clone,
|
||||
) -> bool {
|
||||
#[cfg(unix)]
|
||||
if let [Some(first), Some(second)] = outputs.map(|path| self.path_identity(path)) {
|
||||
let identities = [first, second];
|
||||
for candidate in candidates.clone() {
|
||||
if let Some(output) = outputs.iter().find(|&&output| output == candidate) {
|
||||
return self.record_alias(candidate, output, true);
|
||||
}
|
||||
let observed = if identities == [UnixPathIdentity::Missing; 2] {
|
||||
None
|
||||
} else {
|
||||
self.path_identity(candidate)
|
||||
};
|
||||
for (output, identity) in outputs.into_iter().zip(identities) {
|
||||
let same = if identity == UnixPathIdentity::Missing {
|
||||
self.record_alias(candidate, output, false)
|
||||
} else if let Some(observed) = observed {
|
||||
self.record_alias(candidate, output, identity == observed)
|
||||
} else {
|
||||
self.same_file(candidate, output)
|
||||
};
|
||||
if same {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fresh pairwise checks if either destination changed during the scan.
|
||||
if outputs.map(|path| self.path_identity(path)) == identities.map(Some) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
outputs.into_iter().any(|path| self.aliases_any(path, candidates.clone()))
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn path_identity(&mut self, path: &Path) -> Option<UnixPathIdentity> {
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
|
||||
Reference in new issue
Block a user