From 835806f0eb634b1c4531a2c2a1f5c3ff6d79868f Mon Sep 17 00:00:00 2001 From: abraunegg Date: Mon, 16 Apr 2018 21:39:45 +1000 Subject: [PATCH] Update "hidden" directory & skip_file handling * Partial rollback of 570d42269ea0d28fcfb102be3ff87694807b4655 to original logic behind isNameExcluded() * Removed .* from default skip_file configuration --- src/config.d | 4 +++- src/selective.d | 14 ++++++-------- src/sync.d | 6 ++++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/config.d b/src/config.d index e7a25dbe..91f9c5ad 100644 --- a/src/config.d +++ b/src/config.d @@ -27,7 +27,9 @@ final class Config void init() { setValue("sync_dir", "~/OneDrive"); - setValue("skip_file", ".*|~*"); + // Configure to skip ONLY temp files (~*.doc etc) by default + // Prior configuration was: .*|~* + setValue("skip_file", "~*"); if (!load(userConfigFilePath)) { log.vlog("No config file found, using defaults"); } diff --git a/src/selective.d b/src/selective.d index c7ece8fb..80621498 100644 --- a/src/selective.d +++ b/src/selective.d @@ -27,18 +27,16 @@ final class SelectiveSync this.mask = wild2regex(mask); } + // config file skip_file parameter bool isNameExcluded(string name) { - auto validName = isValidFilename(name); - if (validName){ - // This is a valid filename - do NOT exclude - return false; - } else { - // Invalid file name - exclude this name - return true; - } + // Does the file match skip_file config entry? + // Returns true if the file matches a skip_file config entry + // Returns false if no match + return !name.matchFirst(mask).empty; } + // config sync_list file handling bool isPathExcluded(string path) { return .isPathExcluded(path, paths); diff --git a/src/sync.d b/src/sync.d index 0db0ce77..eacd9978 100644 --- a/src/sync.d +++ b/src/sync.d @@ -731,10 +731,10 @@ final class SyncEngine return; } - // skip filtered items + // filter out user configured items to skip if (path != ".") { if (selectiveSync.isNameExcluded(baseName(path))) { - log.vlog("Skipping item - name excluded: ", path); + log.vlog("Skipping item - excluded by skip_file config: ", path); return; } if (selectiveSync.isPathExcluded(path)) { @@ -743,6 +743,8 @@ final class SyncEngine } } + // This item passed all the unwanted checks + // We want to upload this new item if (isDir(path)) { Item item; if (!itemdb.selectByPath(path, defaultDriveId, item)) {