mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-01 13:32:16 +02:00
Update PR
* Update PR
This commit is contained in:
parent
6e7ab308d0
commit
8d260a6b26
40
src/sync.d
40
src/sync.d
|
@ -78,6 +78,8 @@ class SyncEngine {
|
|||
string[] fileUploadFailures;
|
||||
// List of path names changed online, but not changed locally when using --dry-run
|
||||
string[] pathsRenamed;
|
||||
// List of paths that were a POSIX case-insensitive match, thus could not be created online
|
||||
string[] posixViolationPaths;
|
||||
// Flag that there were upload or download failures listed
|
||||
bool syncFailures = false;
|
||||
// Is sync_list configured
|
||||
|
@ -3929,7 +3931,10 @@ class SyncEngine {
|
|||
string msg = format("POSIX 'case-insensitive match' between '%s' (local) and '%s' (online) which violates the Microsoft OneDrive API namespace convention", baseName(thisNewPathToCreate), onlinePathData["name"].str);
|
||||
displayPosixErrorMessage(msg);
|
||||
log.error("ERROR: Requested directory to create has a 'case-insensitive match' to an existing directory on OneDrive online.");
|
||||
log.error("ERROR: To resolve, rename this local directory: ", buildNormalizedPath(absolutePath(thisNewPathToCreate)));
|
||||
log.log("Skipping creating this directory online due to 'case-insensitive match': ", thisNewPathToCreate);
|
||||
// Add this path to posixViolationPaths
|
||||
posixViolationPaths ~= [thisNewPathToCreate];
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -3942,13 +3947,13 @@ class SyncEngine {
|
|||
}
|
||||
|
||||
// Test that the online name actually matches the requested local name
|
||||
void performPosixTest(string onlineName, string localNameToCheck) {
|
||||
void performPosixTest(string localNameToCheck, string onlineName) {
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file
|
||||
// Do not assume case sensitivity. For example, consider the names OSCAR, Oscar, and oscar to be the same,
|
||||
// even though some file systems (such as a POSIX-compliant file system) may consider them as different.
|
||||
// Note that NTFS supports POSIX semantics for case sensitivity but this is not the default behavior.
|
||||
if (onlineName != localNameToCheck) {
|
||||
if (localNameToCheck != onlineName) {
|
||||
// POSIX Error
|
||||
// Local item name has a 'case-insensitive match' to an existing item on OneDrive
|
||||
throw new posixException(localNameToCheck, onlineName);
|
||||
|
@ -4021,16 +4026,17 @@ class SyncEngine {
|
|||
}
|
||||
}
|
||||
|
||||
// To ensure we are uploading the the right location 'parentItem.driveId' must not be empty
|
||||
if (parentItem.driveId.empty) {
|
||||
// If the parent path was found in the DB, to ensure we are uploading the the right location 'parentItem.driveId' must not be empty
|
||||
if ((parentPathFoundInDB) && (parentItem.driveId.empty)) {
|
||||
// switch to using defaultDriveId
|
||||
log.vdebug("parentItem.driveId is empty - using defaultDriveId for upload API calls");
|
||||
log.log("parentItem.driveId is empty - using defaultDriveId for upload API calls");
|
||||
parentItem.driveId = appConfig.defaultDriveId;
|
||||
}
|
||||
|
||||
// Can we read the file - as a permissions issue or actual file corruption will cause a failure
|
||||
// Resolves: https://github.com/abraunegg/onedrive/issues/113
|
||||
if (readLocalFile(fileToUpload)) {
|
||||
if (parentPathFoundInDB) {
|
||||
// The local file can be read - so we can read it to attemtp to upload it in this thread
|
||||
// Get the file size
|
||||
thisFileSize = getSize(fileToUpload);
|
||||
|
@ -4106,10 +4112,12 @@ class SyncEngine {
|
|||
// Does this 'file' already exist on OneDrive?
|
||||
try {
|
||||
fileDetailsFromOneDrive = checkFileOneDriveApiInstance.getPathDetailsByDriveId(parentItem.driveId, fileToUpload);
|
||||
// Portable Operating System Interface (POSIX) testing of JSON response from OneDrive API
|
||||
performPosixTest(baseName(fileToUpload), fileDetailsFromOneDrive["name"].str);
|
||||
} catch (OneDriveException exception) {
|
||||
// If we get a 404 .. the file is not online .. this is what we want .. file does not exist online
|
||||
if (exception.httpStatusCode == 404) {
|
||||
// The file has been checked, client side filtering checked - we need to upload it
|
||||
// The file has been checked, client side filtering checked, does not exist online - we need to upload it
|
||||
log.vdebug("fileDetailsFromOneDrive = checkFileOneDriveApiInstance.getPathDetailsByDriveId(parentItem.driveId, fileToUpload); generated a 404 - file does not exist online - must upload it");
|
||||
uploadFailed = performNewFileUpload(parentItem, fileToUpload, thisFileSize);
|
||||
} else {
|
||||
|
@ -4146,7 +4154,11 @@ class SyncEngine {
|
|||
}
|
||||
|
||||
}
|
||||
} catch (posixException e) {
|
||||
displayPosixErrorMessage(e.msg);
|
||||
uploadFailed = true;
|
||||
}
|
||||
|
||||
// Operations in this thread are done / complete - either upload was done or it failed
|
||||
checkFileOneDriveApiInstance.shutdown();
|
||||
} else {
|
||||
|
@ -4159,6 +4171,16 @@ class SyncEngine {
|
|||
log.log("Skipping uploading this new file as it exceeds the maximum size allowed by OneDrive: ", fileToUpload);
|
||||
uploadFailed = true;
|
||||
}
|
||||
} else {
|
||||
// why was the parent path not in the database?
|
||||
if (canFind(posixViolationPaths, parentPath)) {
|
||||
log.error("ERROR: POSIX 'case-insensitive match' for the parent path which violates the Microsoft OneDrive API namespace convention.");
|
||||
} else {
|
||||
log.error("ERROR: Parent path is not in the database or online.");
|
||||
}
|
||||
log.error("ERROR: Unable to upload this file: ", fileToUpload);
|
||||
uploadFailed = true;
|
||||
}
|
||||
} else {
|
||||
// Unable to read local file
|
||||
log.log("Skipping uploading this file as it cannot be read (file permissions or file corruption): ", fileToUpload);
|
||||
|
@ -5525,7 +5547,7 @@ class SyncEngine {
|
|||
// Query OneDrive API for this path
|
||||
getPathDetailsAPIResponse = queryOneDriveForSpecificPath.getPathDetails(currentPathTree);
|
||||
// Portable Operating System Interface (POSIX) testing of JSON response from OneDrive API
|
||||
performPosixTest(getPathDetailsAPIResponse["name"].str, thisFolderName);
|
||||
performPosixTest(thisFolderName, getPathDetailsAPIResponse["name"].str);
|
||||
// No POSIX issue with requested path element
|
||||
parentDetails = makeItem(getPathDetailsAPIResponse);
|
||||
saveItem(getPathDetailsAPIResponse);
|
||||
|
@ -5558,10 +5580,6 @@ class SyncEngine {
|
|||
directoryFoundOnline = false;
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string thisFunctionName = getFunctionName!({});
|
||||
// HTTP request returned status code 408,429,503,504
|
||||
if ((exception.httpStatusCode == 408) || (exception.httpStatusCode == 429) || (exception.httpStatusCode == 503) || (exception.httpStatusCode == 504)) {
|
||||
|
|
Loading…
Reference in a new issue