Bug fixed: 1. Replace mkdirRecurse with mkdir to deal nested directory;2. Before download an item, check if its dirName exists, if not, build it.

This commit is contained in:
lanhin 2016-11-23 23:10:37 +08:00
parent eb8d0fe039
commit 7c112304b5
2 changed files with 7 additions and 2 deletions

View file

@ -100,10 +100,14 @@ final class OneDriveApi
void downloadById(const(char)[] id, string saveToPath)
{
checkAccessTokenExpired();
import std.file;
scope(failure) {
import std.file;
if (exists(saveToPath)) remove(saveToPath);
}
// mkdir if need, or File(saveToPath, "wb") may fail
if ( !exists(dirName(saveToPath)) ) {
mkdirRecurse(dirName(saveToPath));
}
const(char)[] url = itemByIdUrl ~ id ~ "/content?AVOverride=1";
download(url, saveToPath);
}

View file

@ -243,7 +243,8 @@ final class SyncEngine
break;
case ItemType.dir:
log.log("Creating directory: ", path);
mkdir(path);
//Use mkdirRecuse to deal nested dir
mkdirRecurse(path);
break;
}
setTimes(path, item.mtime, item.mtime);