Skip to content

Commit 5d836ad

Browse files
committed
Update PR
* Update PR based on testing
1 parent c803fb9 commit 5d836ad

File tree

3 files changed

+184
-65
lines changed

3 files changed

+184
-65
lines changed

src/itemdb.d

+3-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ final class ItemDatabase {
371371
SELECT *
372372
FROM item
373373
WHERE type = 'remote'
374-
AND remoteDriveId = ?1
374+
AND remoteDriveId = ?1 AND remoteId = ?2
375375
";
376376
selectItemByParentIdStmt = "SELECT * FROM item WHERE driveId = ? AND parentId = ?";
377377
deleteItemByIdStmt = "DELETE FROM item WHERE driveId = ? AND id = ?";
@@ -634,12 +634,13 @@ final class ItemDatabase {
634634
}
635635

636636
// This should return the 'remote' DB entry for the given 'remoteDriveId' and 'remoteId'
637-
bool selectRemoteTypeByRemoteDriveId(const(char)[] remoteDriveId, out Item item) {
637+
bool selectRemoteTypeByRemoteDriveId(const(char)[] remoteDriveId, const(char)[] remoteId, out Item item) {
638638
synchronized(databaseLock) {
639639
auto p = db.prepare(selectRemoteTypeByRemoteDriveIdStmt);
640640
scope(exit) p.finalise(); // Ensure that the prepared statement is finalised after execution.
641641
try {
642642
p.bind(1, remoteDriveId);
643+
p.bind(2, remoteId);
643644
auto r = p.exec();
644645
if (!r.empty) {
645646
item = buildItem(r);

src/onedrive.d

+34-6
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,19 @@ class OneDriveApi {
572572
// After you have finished receiving all the changes, you may apply them to your local state. To check for changes in the future, call delta again with the @odata.deltaLink from the previous successful response.
573573
JSONValue getChangesByItemId(string driveId, string id, string deltaLink) {
574574
string[string] requestHeaders;
575-
// If Business Account add Prefer: Include-Feature=AddToOneDrive
576-
if ((appConfig.accountType != "personal") && ( appConfig.getValueBool("sync_business_shared_items"))) {
577-
addIncludeFeatureRequestHeader(&requestHeaders);
575+
576+
// From March 1st 2025, this needs to be added to ensure that Shared Folders are sent in the Delta Query Response
577+
// TO BE CONFIRMED .. adding 'Include-Feature=AddToOneDrive' to header is NOT WORKING for /delta
578+
if (appConfig.accountType == "personal") {
579+
// OneDrive Personal Account
580+
addIncludeFeatureRequestHeader(&requestHeaders); // NOT WORKING !!!!!!!
581+
} else {
582+
// Business or SharePoint Library
583+
// Only add if configured to do so
584+
if (appConfig.getValueBool("sync_business_shared_items")) {
585+
// Feature enabled, add headers
586+
addIncludeFeatureRequestHeader(&requestHeaders);
587+
}
578588
}
579589

580590
string url;
@@ -586,15 +596,26 @@ class OneDriveApi {
586596
} else {
587597
url = deltaLink;
588598
}
599+
600+
// get the response
589601
return get(url, false, requestHeaders);
590602
}
591603

592604
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children
593605
JSONValue listChildren(string driveId, string id, string nextLink) {
594606
string[string] requestHeaders;
595-
// If Business Account add addIncludeFeatureRequestHeader() which should add Prefer: Include-Feature=AddToOneDrive
596-
if ((appConfig.accountType != "personal") && ( appConfig.getValueBool("sync_business_shared_items"))) {
607+
608+
// From March 1st 2025, this needs to be added to ensure that Shared Folders are sent in the Delta Query Response
609+
if (appConfig.accountType == "personal") {
610+
// OneDrive Personal Account
597611
addIncludeFeatureRequestHeader(&requestHeaders);
612+
} else {
613+
// Business or SharePoint Library
614+
// Only add if configured to do so
615+
if (appConfig.getValueBool("sync_business_shared_items")) {
616+
// Feature enabled, add headers
617+
addIncludeFeatureRequestHeader(&requestHeaders);
618+
}
598619
}
599620

600621
string url;
@@ -819,7 +840,14 @@ class OneDriveApi {
819840

820841
// Private OneDrive API Functions
821842
private void addIncludeFeatureRequestHeader(string[string]* headers) {
822-
if (debugLogging) {addLogEntry("Adding 'Include-Feature=AddToOneDrive' API request header as 'sync_business_shared_items' config option is enabled", ["debug"]);}
843+
if (appConfig.accountType == "personal") {
844+
// Add logging message for OneDrive Personal Accounts
845+
if (debugLogging) {addLogEntry("Adding 'Include-Feature=AddToOneDrive' API request header for OneDrive Personal Account Type", ["debug"]);}
846+
} else {
847+
// Add logging message for OneDrive Business Accounts
848+
if (debugLogging) {addLogEntry("Adding 'Include-Feature=AddToOneDrive' API request header as 'sync_business_shared_items' config option is enabled", ["debug"]);}
849+
}
850+
// Add feature to request headers
823851
(*headers)["Prefer"] = "Include-Feature=AddToOneDrive";
824852
}
825853

0 commit comments

Comments
 (0)