Update long path handling

* Update long path handling to account for differences between OneDrive Personal and OneDrive Business Accounts
* Update logging to be cleaner on fragment uploads
This commit is contained in:
abraunegg 2018-05-09 06:47:03 +10:00
parent 0ca87cb92d
commit 41976ed216
2 changed files with 26 additions and 12 deletions

View file

@ -487,7 +487,7 @@ final class OneDriveApi
// 204 - Deleted OK
case 201,202,204:
// No actions, but log if verbose logging
log.vlog("OneDrive Response: '", http.statusLine.code, " - ", http.statusLine.reason, "'");
//log.vlog("OneDrive Response: '", http.statusLine.code, " - ", http.statusLine.reason, "'");
break;
// 400 - Bad Request

View file

@ -781,6 +781,7 @@ final class SyncEngine
} else {
writeln("");
response = session.upload(path, item.driveId, item.parentId, baseName(path), eTag);
writeln(" done.");
}
log.fileOnly("Uploading file ", path, " ... done.");
// saveItem(response); redundant
@ -805,10 +806,21 @@ final class SyncEngine
private void uploadNewItems(string path)
{
// https://github.com/OneDrive/onedrive-api-docs/issues/443
// If the path is greater than 430 characters, then one drive will return a '400 - Bad Request'
// If the path is greater than allowed characters, then one drive will return a '400 - Bad Request'
// Need to ensure that the URI is encoded before the check is made
if(encodeComponent(path).length < 430){
// path is less than 430 characters
// 256 Character Limit for OneDrive Business / Office 365
// 430 Character Limit for OneDrive Personal
auto maxPathLength = 0;
if (accountType == "business"){
// Business Account
maxPathLength = 256;
} else {
// Personal Account
maxPathLength = 430;
}
if(encodeComponent(path).length < maxPathLength){
// path is less than maxPathLength
// skip unexisting symbolic links
if (isSymlink(path) && !exists(readLink(path))) {
@ -864,7 +876,7 @@ final class SyncEngine
}
} else {
// This path was skipped - why?
log.log("Skipping item '", path, "' due to the full path exceeding 430 characters (Microsoft OneDrive limitation)");
log.log("Skipping item '", path, "' due to the full path exceeding ", maxPathLength, " characters (Microsoft OneDrive limitation)");
}
}
@ -983,6 +995,7 @@ final class SyncEngine
} else {
writeln("");
response = session.upload(path, parent.driveId, parent.id, baseName(path));
writeln(" done.");
}
log.fileOnly("Uploading file ", path, " ... done.");
@ -1014,6 +1027,7 @@ final class SyncEngine
} else {
writeln("");
response = session.upload(path, parent.driveId, parent.id, baseName(path));
writeln(" done.");
}
log.fileOnly("Uploading file ", path, " ... done.");
string id = response["id"].str;