From b4c3da6e103c8e01f94f9ed163e942881570be41 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Thu, 5 Nov 2020 04:51:35 +1100 Subject: [PATCH] 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 --- src/selective.d | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/selective.d b/src/selective.d index 4c81bb84..ecc7e734 100644 --- a/src/selective.d +++ b/src/selective.d @@ -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