Fix issue of trying to create the root folder online (#3403)

* Fix issue of trying to create the root folder online (which is denoted by a '.') as this will never be possible.
This commit is contained in:
abraunegg 2025-08-02 07:22:32 +10:00 committed by GitHub
commit b6fa6f8fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -7907,7 +7907,20 @@ class SyncEngine {
displayFunctionProcessingStart(thisFunctionName, logKey);
}
// Log what we are doing
// Is this a valid path to create?
// We need to avoid this sort of error:
//
// OneDrive generated an error when creating this path: .
// ERROR: Microsoft OneDrive API returned an error with the following message:
// Error Message: HTTP request returned status code 400 (Bad Request)
// Error Reason: Invalid request
// Error Code: invalidRequest
// Error Timestamp: 2025-08-01T21:08:26
// API Request ID: dca77bd6-1e9a-432a-bc6c-1c6b5380745d
if (isRootEquivalent(thisNewPathToCreate)) return;
// Log what path we are attempting to create online
if (verboseLogging) {addLogEntry("OneDrive Client requested to create this directory online: " ~ thisNewPathToCreate, ["verbose"]);}
// Function variables

View file

@ -1396,6 +1396,12 @@ bool hasSHA256HashResume(const ref JSONValue item) {
return ("sha256Hash" in item["onlineHash"]) != null;
}
// Test if a path is the equivalent of root '.'
bool isRootEquivalent(string inputPath) {
auto normalisedPath = buildNormalizedPath(inputPath);
return normalisedPath == "." || normalisedPath == "";
}
// Convert bytes to GB
string byteToGibiByte(ulong bytes) {
if (bytes == 0) {