Check the given local path in reverse order for a skip_dir match on --resync (#1125)

* When matching skip_dir entries, if there is no direct first match, perform a reverse directory walk to test each path block for a match
This commit is contained in:
abraunegg 2020-11-05 04:51:35 +11:00 committed by GitHub
parent 363f64df36
commit b4c3da6e10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,15 +89,30 @@ final class SelectiveSync
// Try full path match first
if (!name.matchFirst(dirmask).empty) {
log.vdebug("'!name.matchFirst(dirmask).empty' returned true = matched");
return true;
} else {
// Do we check the base name as well?
if (!skipDirStrictMatch) {
// check just the basename in the path
string parent = baseName(name);
if(!parent.matchFirst(dirmask).empty) {
return true;
log.vdebug("No Strict Matching Enforced");
// Test the entire path working backwards from child
string path = buildNormalizedPath(name);
string checkPath;
auto paths = pathSplitter(path);
foreach_reverse(directory; paths) {
if (directory != "/") {
// This will add a leading '/' but that needs to be stripped to check
checkPath = "/" ~ directory ~ checkPath;
if(!checkPath.strip('/').matchFirst(dirmask).empty) {
log.vdebug("'!checkPath.matchFirst(dirmask).empty' returned true = matched");
return true;
}
}
}
} else {
log.vdebug("Strict Matching Enforced - No Match");
}
}
// no match