INNER CODE UNIT · Rust
Some
XayahSuSuSu/Android-DataBackup · source-next/native/src/main/jni/rustic/src/mapped_source.rs:66
if let Some((_, existing)) = paths.iter().find(|(previous, _)| *previous == source) {
if *existing != destination {
return Err("A physical source has conflicting snapshot mappings".into());
}
continue;
}
paths.push((source, destination));
}
paths.sort();
// Discard child mappings that are identical to their parent's inherited mapping.
let mut retained: Vec<(PathBuf, PathBuf)> = Vec::new();
for (source, destination) in paths {
let parent = retained
.iter()
.filter(|(root, _)| source.starts_with(root))
.max_by_key(|(root, _)| root.components().count());
if parent.is_some_and(|(root, mapped)| {
mapped.join(source.strip_prefix(root).unwrap()) == destination