From 68c6c5d75dd9116efc185150043ee87eb20dcef5 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 12 Jul 2019 13:12:26 +1000 Subject: [PATCH] Fix hidden directories in 'root' from having prefix removed (#586) * Fix hidden directories in 'root' from having prefix removed --- src/itemdb.d | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/itemdb.d b/src/itemdb.d index 8b39f3d5..4b6ddffe 100644 --- a/src/itemdb.d +++ b/src/itemdb.d @@ -212,7 +212,16 @@ final class ItemDatabase bool selectByPath(const(char)[] path, string rootDriveId, out Item item) { Item currItem = { driveId: rootDriveId }; - path = "root/" ~ path.chompPrefix("."); + + // Issue https://github.com/abraunegg/onedrive/issues/578 + if (startsWith(path, "./") || path == ".") { + // Need to remove the . from the path prefix + path = "root/" ~ path.chompPrefix("."); + } else { + // Leave path as it is + path = "root/" ~ path; + } + auto s = db.prepare("SELECT * FROM item WHERE name = ?1 AND driveId IS ?2 AND parentId IS ?3"); foreach (name; pathSplitter(path)) { s.bind(1, name); @@ -238,7 +247,16 @@ final class ItemDatabase bool selectByPathNoRemote(const(char)[] path, string rootDriveId, out Item item) { Item currItem = { driveId: rootDriveId }; - path = "root/" ~ path.chompPrefix("."); + + // Issue https://github.com/abraunegg/onedrive/issues/578 + if (startsWith(path, "./") || path == ".") { + // Need to remove the . from the path prefix + path = "root/" ~ path.chompPrefix("."); + } else { + // Leave path as it is + path = "root/" ~ path; + } + auto s = db.prepare("SELECT * FROM item WHERE name IS ?1 AND driveId IS ?2 AND parentId IS ?3"); foreach (name; pathSplitter(path)) { s.bind(1, name);