Fix hidden directories in 'root' from having prefix removed (#586)

* Fix hidden directories in 'root' from having prefix removed
This commit is contained in:
abraunegg 2019-07-12 13:12:26 +10:00 committed by GitHub
parent c16ba1ba2f
commit 68c6c5d75d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);