mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-02 22:12:33 +02:00
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:
parent
0ca87cb92d
commit
41976ed216
|
@ -487,7 +487,7 @@ final class OneDriveApi
|
||||||
// 204 - Deleted OK
|
// 204 - Deleted OK
|
||||||
case 201,202,204:
|
case 201,202,204:
|
||||||
// No actions, but log if verbose logging
|
// 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;
|
break;
|
||||||
|
|
||||||
// 400 - Bad Request
|
// 400 - Bad Request
|
||||||
|
|
22
src/sync.d
22
src/sync.d
|
@ -781,6 +781,7 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
writeln("");
|
writeln("");
|
||||||
response = session.upload(path, item.driveId, item.parentId, baseName(path), eTag);
|
response = session.upload(path, item.driveId, item.parentId, baseName(path), eTag);
|
||||||
|
writeln(" done.");
|
||||||
}
|
}
|
||||||
log.fileOnly("Uploading file ", path, " ... done.");
|
log.fileOnly("Uploading file ", path, " ... done.");
|
||||||
// saveItem(response); redundant
|
// saveItem(response); redundant
|
||||||
|
@ -805,10 +806,21 @@ final class SyncEngine
|
||||||
private void uploadNewItems(string path)
|
private void uploadNewItems(string path)
|
||||||
{
|
{
|
||||||
// https://github.com/OneDrive/onedrive-api-docs/issues/443
|
// 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
|
// Need to ensure that the URI is encoded before the check is made
|
||||||
if(encodeComponent(path).length < 430){
|
// 256 Character Limit for OneDrive Business / Office 365
|
||||||
// path is less than 430 characters
|
// 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
|
// skip unexisting symbolic links
|
||||||
if (isSymlink(path) && !exists(readLink(path))) {
|
if (isSymlink(path) && !exists(readLink(path))) {
|
||||||
|
@ -864,7 +876,7 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This path was skipped - why?
|
// 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 {
|
} else {
|
||||||
writeln("");
|
writeln("");
|
||||||
response = session.upload(path, parent.driveId, parent.id, baseName(path));
|
response = session.upload(path, parent.driveId, parent.id, baseName(path));
|
||||||
|
writeln(" done.");
|
||||||
}
|
}
|
||||||
log.fileOnly("Uploading file ", path, " ... done.");
|
log.fileOnly("Uploading file ", path, " ... done.");
|
||||||
|
|
||||||
|
@ -1014,6 +1027,7 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
writeln("");
|
writeln("");
|
||||||
response = session.upload(path, parent.driveId, parent.id, baseName(path));
|
response = session.upload(path, parent.driveId, parent.id, baseName(path));
|
||||||
|
writeln(" done.");
|
||||||
}
|
}
|
||||||
log.fileOnly("Uploading file ", path, " ... done.");
|
log.fileOnly("Uploading file ", path, " ... done.");
|
||||||
string id = response["id"].str;
|
string id = response["id"].str;
|
||||||
|
|
Loading…
Reference in a new issue