From b6fa6f8fe475acbd672b53528bb51670f57c4ac8 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 2 Aug 2025 07:22:32 +1000 Subject: [PATCH] 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. --- src/sync.d | 15 ++++++++++++++- src/util.d | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/sync.d b/src/sync.d index 8835da0f..c244c68c 100644 --- a/src/sync.d +++ b/src/sync.d @@ -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 diff --git a/src/util.d b/src/util.d index 8a7cda61..ccf40954 100644 --- a/src/util.d +++ b/src/util.d @@ -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) {