mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-14 03:36:52 +02:00
case insensitive patterns
This commit is contained in:
parent
d2ec6c688f
commit
7ea7c0f9cd
|
@ -40,8 +40,8 @@ struct Monitor
|
|||
void init(Config cfg, bool verbose)
|
||||
{
|
||||
this.verbose = verbose;
|
||||
skipDir = regex(wild2regex(cfg.get("skip_dir", "")));
|
||||
skipFile = regex(wild2regex(cfg.get("skip_file", "")));
|
||||
skipDir = wild2regex(cfg.get("skip_dir", ""));
|
||||
skipFile = wild2regex(cfg.get("skip_file", ""));
|
||||
fd = inotify_init();
|
||||
if (fd == -1) throw new MonitorException("inotify_init failed");
|
||||
if (!buffer) buffer = new void[4096];
|
||||
|
|
|
@ -219,7 +219,6 @@ final class OneDriveApi
|
|||
private void checkAccessTokenExpired()
|
||||
{
|
||||
if (Clock.currTime() >= accessTokenExpiration) {
|
||||
writeln("Access token expired, requesting a new token...");
|
||||
newToken();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ final class SyncEngine
|
|||
this.onedrive = onedrive;
|
||||
this.itemdb = itemdb;
|
||||
this.verbose = verbose;
|
||||
skipDir = regex(wild2regex(cfg.get("skip_dir", "")));
|
||||
skipFile = regex(wild2regex(cfg.get("skip_file", "")));
|
||||
skipDir = wild2regex(cfg.get("skip_dir", ""));
|
||||
skipFile = wild2regex(cfg.get("skip_file", ""));
|
||||
}
|
||||
|
||||
void setStatusToken(string statusToken)
|
||||
|
|
31
src/util.d
31
src/util.d
|
@ -1,10 +1,5 @@
|
|||
import std.conv: to;
|
||||
import std.digest.crc;
|
||||
import std.digest.digest;
|
||||
import std.file: exists, rename;
|
||||
import std.path: extension;
|
||||
import std.stdio;
|
||||
import std.string: chomp;
|
||||
import std.conv, std.digest.crc, std.digest.digest, std.file, std.path;
|
||||
import std.regex, std.stdio, std.string: chomp;
|
||||
|
||||
private string deviceName;
|
||||
|
||||
|
@ -44,30 +39,30 @@ string computeCrc32(string path)
|
|||
}
|
||||
|
||||
// convert wildcards (*, ?) to regex
|
||||
string wild2regex(const(char)[] pattern)
|
||||
Regex!char wild2regex(const(char)[] pattern)
|
||||
{
|
||||
string regex;
|
||||
regex.reserve(pattern.length + 2);
|
||||
regex ~= "(^|/)";
|
||||
string str;
|
||||
str.reserve(pattern.length + 2);
|
||||
str ~= "(^|/)";
|
||||
foreach (c; pattern) {
|
||||
switch (c) {
|
||||
case '*':
|
||||
regex ~= "[^/]*";
|
||||
str ~= "[^/]*";
|
||||
break;
|
||||
case '.':
|
||||
regex ~= "\\.";
|
||||
str ~= "\\.";
|
||||
break;
|
||||
case '?':
|
||||
regex ~= "[^/]";
|
||||
str ~= "[^/]";
|
||||
break;
|
||||
case '|':
|
||||
regex ~= "$|(^|/)";
|
||||
str ~= "$|(^|/)";
|
||||
break;
|
||||
default:
|
||||
regex ~= c;
|
||||
str ~= c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
regex ~= "$";
|
||||
return regex;
|
||||
str ~= "$";
|
||||
return regex(str, "i");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue