mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-07 08:22:13 +02:00
Fix Business Shared Folder handling to process only Business Shared Folders (#1104)
* Update Business Shared Folder handling to process only Shared Folders, not individually shared files
This commit is contained in:
parent
9ca2f6ae26
commit
fe86dd1809
51
src/sync.d
51
src/sync.d
|
@ -598,6 +598,22 @@ final class SyncEngine
|
|||
if (graphQuery.type() == JSONType.object) {
|
||||
string sharedFolderName;
|
||||
foreach (searchResult; graphQuery["value"].array) {
|
||||
// Configure additional logging items for this array element
|
||||
string sharedByName;
|
||||
string sharedByEmail;
|
||||
// Extra details for verbose logging
|
||||
if ("sharedBy" in searchResult["remoteItem"]["shared"]) {
|
||||
if ("displayName" in searchResult["remoteItem"]["shared"]["sharedBy"]["user"]) {
|
||||
sharedByName = searchResult["remoteItem"]["shared"]["sharedBy"]["user"]["displayName"].str;
|
||||
}
|
||||
if ("email" in searchResult["remoteItem"]["shared"]["sharedBy"]["user"]) {
|
||||
sharedByEmail = searchResult["remoteItem"]["shared"]["sharedBy"]["user"]["email"].str;
|
||||
}
|
||||
}
|
||||
|
||||
// is the shared item with us a 'folder' ?
|
||||
if (isItemFolder(searchResult)) {
|
||||
// item returned is a shared folder, not a shared file
|
||||
sharedFolderName = searchResult["name"].str;
|
||||
// Compare this to values in business_shared_folders
|
||||
if(selectiveSync.isSharedFolderMatched(sharedFolderName)){
|
||||
|
@ -647,20 +663,6 @@ final class SyncEngine
|
|||
log.vdebug("database drive id matches defaultDriveId: ", itemPathIsLocal);
|
||||
log.vdebug("database data matches search data: ", ((databaseItem.driveId == searchResult["remoteItem"]["parentReference"]["driveId"].str) && (databaseItem.id == searchResult["remoteItem"]["id"].str)));
|
||||
|
||||
// Additional logging
|
||||
string sharedByName;
|
||||
string sharedByEmail;
|
||||
|
||||
// Extra details for verbose logging
|
||||
if ("sharedBy" in searchResult["remoteItem"]["shared"]) {
|
||||
if ("displayName" in searchResult["remoteItem"]["shared"]["sharedBy"]["user"]) {
|
||||
sharedByName = searchResult["remoteItem"]["shared"]["sharedBy"]["user"]["displayName"].str;
|
||||
}
|
||||
if ("email" in searchResult["remoteItem"]["shared"]["sharedBy"]["user"]) {
|
||||
sharedByEmail = searchResult["remoteItem"]["shared"]["sharedBy"]["user"]["email"].str;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ((!itemInDatabase) || (!itemLocalDirExists)) || (((databaseItem.driveId == searchResult["remoteItem"]["parentReference"]["driveId"].str) && (databaseItem.id == searchResult["remoteItem"]["id"].str)) && (!itemPathIsLocal)) ) {
|
||||
// This shared folder does not exist in the database
|
||||
if (!cfg.getValueBool("monitor")) {
|
||||
|
@ -704,6 +706,27 @@ final class SyncEngine
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// not a folder, is this a file?
|
||||
if (isItemFile(searchResult)) {
|
||||
// shared item is a file
|
||||
string sharedFileName = searchResult["name"].str;
|
||||
// log that this is not supported
|
||||
log.vlog("WARNING: Not syncing this OneDrive Business Shared File: ", sharedFileName);
|
||||
|
||||
// Log who shared this to assist with sync data correlation
|
||||
if ((sharedByName != "") && (sharedByEmail != "")) {
|
||||
log.vlog("OneDrive Business Shared File - Shared By: ", sharedByName, " (", sharedByEmail, ")");
|
||||
} else {
|
||||
if (sharedByName != "") {
|
||||
log.vlog("OneDrive Business Shared File - Shared By: ", sharedByName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// something else entirely
|
||||
log.log("WARNING: Not syncing this OneDrive Business Shared item: ", searchResult["name"].str);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Log that an invalid JSON object was returned
|
||||
|
|
Loading…
Reference in a new issue