From 0ce088f0e26c04cc4db617f3cdb5a7d93d6a83e6 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 13 Jan 2024 16:03:43 +1100 Subject: [PATCH] Update 'root:' removal for 'skip_dir' path checking * Update 'root:' removal for 'skip_dir' path checking --- src/sync.d | 35 ++++++++++++++++++++++------------- src/util.d | 2 +- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/sync.d b/src/sync.d index a7d2e162..f431a220 100644 --- a/src/sync.d +++ b/src/sync.d @@ -1379,16 +1379,15 @@ class SyncEngine { simplePathToCheck = onedriveJSONItem["name"].str; } - // If 'simplePathToCheck' or 'complexPathToCheck' is of the following format: root:/folder + // If 'simplePathToCheck' or 'complexPathToCheck' is of the following format: root:/folder // then isDirNameExcluded matching will not work - // Clean up 'root:' if present - if (startsWith(simplePathToCheck, "root:")){ + if (simplePathToCheck.canFind(":")) { addLogEntry("Updating simplePathToCheck to remove 'root:'", ["debug"]); - simplePathToCheck = strip(simplePathToCheck, "root:"); + simplePathToCheck = processPathToRemoveRootReference(simplePathToCheck); } - if (startsWith(complexPathToCheck, "root:")){ + if (complexPathToCheck.canFind(":")) { addLogEntry("Updating complexPathToCheck to remove 'root:'", ["debug"]); - complexPathToCheck = strip(complexPathToCheck, "root:"); + complexPathToCheck = processPathToRemoveRootReference(complexPathToCheck); } // OK .. what checks are we doing? @@ -3233,16 +3232,15 @@ class SyncEngine { simplePathToCheck = onedriveJSONItem["name"].str; } - // If 'simplePathToCheck' or 'complexPathToCheck' is of the following format: root:/folder + // If 'simplePathToCheck' or 'complexPathToCheck' is of the following format: root:/folder // then isDirNameExcluded matching will not work - // Clean up 'root:' if present - if (startsWith(simplePathToCheck, "root:")){ + if (simplePathToCheck.canFind(":")) { addLogEntry("Updating simplePathToCheck to remove 'root:'", ["debug"]); - simplePathToCheck = strip(simplePathToCheck, "root:"); + simplePathToCheck = processPathToRemoveRootReference(simplePathToCheck); } - if (startsWith(complexPathToCheck, "root:")){ + if (complexPathToCheck.canFind(":")) { addLogEntry("Updating complexPathToCheck to remove 'root:'", ["debug"]); - complexPathToCheck = strip(complexPathToCheck, "root:"); + complexPathToCheck = processPathToRemoveRootReference(complexPathToCheck); } // OK .. what checks are we doing? @@ -3266,7 +3264,7 @@ class SyncEngine { } } // End Result - addLogEntry("skip_dir exclude result (directory based): " ~ clientSideRuleExcludesPath, ["debug"]); + addLogEntry("skip_dir exclude result (directory based): " ~ to!string(clientSideRuleExcludesPath), ["debug"]); if (clientSideRuleExcludesPath) { // This path should be skipped addLogEntry("Skipping item - excluded by skip_dir config: " ~ matchDisplay, ["verbose"]); @@ -7541,4 +7539,15 @@ class SyncEngine { object.destroy(uploadFileOneDriveApiInstance); } } + + // Function to process the path by removing prefix up to ':' - remove '/drive/root:' from a path string + string processPathToRemoveRootReference(ref string pathToCheck) { + long colonIndex = pathToCheck.indexOf(":"); + if (colonIndex != -1) { + addLogEntry("Updating " ~ pathToCheck ~ " to remove prefix up to ':'", ["debug"]); + pathToCheck = pathToCheck[colonIndex + 1 .. $]; + addLogEntry("Updated path for 'skip_dir' check: " ~ pathToCheck, ["debug"]); + } + return pathToCheck; + } } \ No newline at end of file diff --git a/src/util.d b/src/util.d index 518b608a..68ae4182 100644 --- a/src/util.d +++ b/src/util.d @@ -167,7 +167,7 @@ Regex!char wild2regex(const(char)[] pattern) { str ~= "\\+"; break; case ' ': - str ~= "\\s"; // Changed to match exactly one whitespace. str ~= "\\s+"; + str ~= "\\s"; // Changed to match exactly one whitespace. Was: str ~= "\\s+"; break; case '/': str ~= "\\/";