fix: sub directory decision logic on windows

Diff of "C:\foo" from "D:\" is "C:\foo" and doesn't contain "..". In old
logic, "C:\foo" is treated as subpath of "D:\" but this is not
intuitive.
This commit is contained in:
qwjyh 2024-12-01 20:37:23 +09:00
parent dbc0d78f99
commit ced354bf58

View file

@ -135,7 +135,11 @@ fn parent_backups<'a>(
trace!("{:?}", backup_path.components());
let diff = pathdiff::diff_paths(&target_path, backup_path.clone())?;
trace!("Backup: {:?}, Diff: {:?}", backup_path, diff);
if diff.components().any(|c| c == path::Component::ParentDir) {
// note: Should `RootDir` is included in this list?
if diff
.components()
.any(|c| matches!(c, path::Component::ParentDir | path::Component::Prefix(_)))
{
None
} else {
Some((backup, diff))