mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-11 02:06:40 +02:00
* Update skip_file handling by using updated wild2regex to check files & paths of items to skip ro resolve issue #52
This commit is contained in:
parent
4667ecad12
commit
c0d2874ace
|
@ -39,7 +39,7 @@ final class SelectiveSync
|
||||||
// config sync_list file handling
|
// config sync_list file handling
|
||||||
bool isPathExcluded(string path)
|
bool isPathExcluded(string path)
|
||||||
{
|
{
|
||||||
return .isPathExcluded(path, paths);
|
return .isPathExcluded(path, paths) || .isPathMatched(path, mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,24 @@ private bool isPathExcluded(string path, string[] allowedPaths)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test if the given path is matched by the regex expression.
|
||||||
|
// recursively test up the tree.
|
||||||
|
private bool isPathMatched(string path, Regex!char mask) {
|
||||||
|
path = buildNormalizedPath(path);
|
||||||
|
auto paths = pathSplitter(path);
|
||||||
|
|
||||||
|
string prefix = "";
|
||||||
|
foreach(base; paths) {
|
||||||
|
prefix ~= base;
|
||||||
|
if (!path.matchFirst(mask).empty) {
|
||||||
|
// the given path matches something which we should skip
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
prefix ~= dirSeparator;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
assert(isPathExcluded("Documents2", ["Documents"]));
|
assert(isPathExcluded("Documents2", ["Documents"]));
|
||||||
|
|
|
@ -99,7 +99,13 @@ Regex!char wild2regex(const(char)[] pattern)
|
||||||
break;
|
break;
|
||||||
case '+':
|
case '+':
|
||||||
str ~= "\\+";
|
str ~= "\\+";
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
str ~= "\\s+";
|
||||||
break;
|
break;
|
||||||
|
case '/':
|
||||||
|
str ~= "\\/";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
str ~= c;
|
str ~= c;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue