Update 'root:' removal for 'skip_dir' path checking

* Update 'root:' removal for 'skip_dir' path checking
This commit is contained in:
abraunegg 2024-01-13 16:03:43 +11:00
parent d20b62da57
commit 0ce088f0e2
2 changed files with 23 additions and 14 deletions

View file

@ -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;
}
}

View file

@ -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 ~= "\\/";