From b703a824c719c4ba949f443bbea18f6f635ff10c Mon Sep 17 00:00:00 2001 From: skilion Date: Thu, 15 Jun 2017 12:59:33 +0200 Subject: [PATCH] compute path before performing selective sync --- src/sync.d | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/sync.d b/src/sync.d index ae907b32..f7c883f4 100644 --- a/src/sync.d +++ b/src/sync.d @@ -192,24 +192,26 @@ final class SyncEngine Item item = makeItem(jsonItem); log.vlog(item.id, " ", item.name); - // skip unwanted items early + string path = "."; bool unwanted; unwanted |= skippedItems.find(item.parentId).length != 0; unwanted |= selectiveSync.isNameExcluded(item.name); - unwanted |= selectiveSync.isPathExcluded(path); + + if (!unwanted && !isItemRoot(jsonItem)) { + // delay path computation after assuring the item parent is not excluded + path = itemdb.computePath(item.parentDriveId, item.parentId) ~ "/" ~ item.name; + // selective sync + unwanted |= selectiveSync.isPathExcluded(path); + } + + // skip unwanted items early if (unwanted) { log.vlog("Filtered out"); skippedItems ~= item.id; return; } - // compute the path of the item - string path = "."; - if (!isItemRoot(jsonItem)) { - path = itemdb.computePath(item.driveId, item.parentId) ~ "/" ~ item.name; - } - - // check if the item is to be deleted + // check if the item is going to be deleted if (isItemDeleted(jsonItem)) { log.vlog("The item is marked for deletion"); idsToDelete ~= [item.driveId, item.id];