Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OneDrive Personal Drive ID and Remote Drive ID length check #3075

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,7 @@ class SyncEngine {
addLogEntry("The item to sync is already present on the local filesystem and is in-sync with what is reported online", ["debug"]);
addLogEntry("Update/Insert local database with item details: " ~ to!string(newDatabaseItem), ["debug"]);
}
// Add item to database
itemDB.upsert(newDatabaseItem);

// With the 'newDatabaseItem' saved to the database, regardless of --dry-run situation - was that new database item a 'remote' item?
Expand Down Expand Up @@ -2485,6 +2486,7 @@ class SyncEngine {

// Try and fetch this shared folder parent's details
try {
if (debugLogging) {addLogEntry(format("Fetching online data for parentDriveId '%s' and parentObjectId '%s'", parentDriveId, parentObjectId), ["debug"]);}
onlineParentData = onlineParentOneDriveApiInstance.getPathDetailsById(parentDriveId, parentObjectId);
} catch (OneDriveException exception) {
// If we get a 404 .. the shared item does not exist online ... perhaps a broken 'Add shortcut to My files' link in the account holders directory?
Expand Down Expand Up @@ -7417,6 +7419,37 @@ class SyncEngine {
}
}

// OneDrive Personal Account driveId and remoteDriveId length check
// Issue #3072 (https://github.com/abraunegg/onedrive/issues/3072) illustrated that the OneDrive API is inconsistent in response for:
// - driveId
// - remoteDriveId
// When the Drive ID starts with a zero ('0')
// Example:
// 024470056f5c3e43 (driveId)
// 24470056f5c3e43 (remoteDriveId)
// If we this is a OneDrive Personal Account, ensure that these values are 16 characters, padded by leading zero's if needed
// What account type is this?
if (appConfig.accountType == "personal") {

// Check the newDatabaseItem.driveId
if (!newDatabaseItem.driveId.empty) {
// Ensure driveId is 16 characters long by padding with leading zeros if required
if (newDatabaseItem.driveId.length < 16) {
if (debugLogging) {addLogEntry("ONEDRIVE PERSONAL API BUG: The provided DriveID is not 16 Characters in length - padding with leading zero's", ["debug"]);}
newDatabaseItem.driveId = format("%16s", newDatabaseItem.driveId).replace(" ", "0");
}
}

// Check the newDatabaseItem.remoteDriveId
if (!newDatabaseItem.remoteDriveId.empty) {
// Ensure remoteDriveId is 16 characters long by padding with leading zeros if required
if (newDatabaseItem.driveId.length < 16) {
if (debugLogging) {addLogEntry("ONEDRIVE PERSONAL API BUG: The provided RemoteDriveID is not 16 Characters in length - padding with leading zero's", ["debug"]);}
newDatabaseItem.driveId = format("%16s", newDatabaseItem.driveId).replace(" ", "0");
}
}
}

// Return the new database item
return newDatabaseItem;
}
Expand Down
Loading