Support multiple 'document libraries' within a single Shared Library Site (#1350)

* Support providing the 'drive_id' for multiple 'document libraries' within a single Shared Library Site
This commit is contained in:
abraunegg 2021-03-17 18:23:01 +11:00 committed by GitHub
parent 6bec0ddc64
commit 037a6b43e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 17 deletions

View file

@ -14,18 +14,38 @@ Syncing a OneDrive SharePoint library requires additional configuration for your
## Query that shared library name using the client to obtain the required configuration details ## Query that shared library name using the client to obtain the required configuration details
2. Run the following command using the 'onedrive' client 2. Run the following command using the 'onedrive' client
```text ```text
onedrive --get-O365-drive-id '<your library name>' onedrive --get-O365-drive-id '<your site name to search>'
``` ```
This will return something similar to the following: This will return something similar to the following:
```text ```text
Configuration file successfully loaded Configuration file successfully loaded
Configuring Global Azure AD Endpoints Configuring Global Azure AD Endpoints
Initializing the Synchronization Engine ... Initializing the Synchronization Engine ...
Office 365 Library Name Query: <your library name> Office 365 Library Name Query: <your site name to search>
SiteName: <your library name> -----------------------------------------------
drive_id: b!6H_y8B...xU5 Site Name: <your site name>
URL: <your site URL> Library Name: <your library name>
drive_id: b!6H_y8B...xU5
Library URL: <your library URL>
-----------------------------------------------
``` ```
If there are no matches to the site you are attempting to search, the following will be displayed:
```text
Configuration file successfully loaded
Configuring Global Azure AD Endpoints
Initializing the Synchronization Engine ...
Office 365 Library Name Query: blah
ERROR: The requested SharePoint site could not be found. Please check it's name and your permissions to access the site.
The following SharePoint site names were returned:
* <site name 1>
* <site name 2>
...
* <site name X>
```
This list of site names can be used as a basis to search for the correct site for which you are searching
## Configure the client's config file with the required 'drive_id' & 'sync_dir' options ## Configure the client's config file with the required 'drive_id' & 'sync_dir' options
3. Create a new local folder to store the SharePoint Library data in 3. Create a new local folder to store the SharePoint Library data in
@ -54,6 +74,5 @@ The OneDrive client will now be configured to sync this SharePoint shared librar
## Sync the SharePoint Library as required ## Sync the SharePoint Library as required
6. Sync the SharePoint Library to your system with either `--synchronize` or `--monitor` operations 6. Sync the SharePoint Library to your system with either `--synchronize` or `--monitor` operations
# How to configure multiple OneDrive SharePoint Shared Library sync # How to configure multiple OneDrive SharePoint Shared Library sync
Refer to [./advanced-usage.md](advanced-usage.md) for configuration assistance. Refer to [./advanced-usage.md](advanced-usage.md) for configuration assistance.

View file

@ -5390,7 +5390,6 @@ final class SyncEngine
string site_id; string site_id;
string drive_id; string drive_id;
string webUrl;
bool found = false; bool found = false;
JSONValue siteQuery; JSONValue siteQuery;
string nextLink; string nextLink;
@ -5452,12 +5451,11 @@ final class SyncEngine
// Need an 'exclusive' match here with o365SharedLibraryName as entered // Need an 'exclusive' match here with o365SharedLibraryName as entered
log.vdebug("Found O365 Site: ", searchResult); log.vdebug("Found O365 Site: ", searchResult);
// 'displayName', 'id' and 'webUrl' have to be present in the search result record // 'displayName' and 'id' have to be present in the search result record in order to query the site
if (("displayName" in searchResult) && ("id" in searchResult) && ("webUrl" in searchResult)) { if (("displayName" in searchResult) && ("id" in searchResult)) {
if (o365SharedLibraryName == searchResult["displayName"].str){ if (o365SharedLibraryName == searchResult["displayName"].str){
// 'displayName' matches search request // 'displayName' matches search request
site_id = searchResult["id"].str; site_id = searchResult["id"].str;
webUrl = searchResult["webUrl"].str;
JSONValue siteDriveQuery; JSONValue siteDriveQuery;
try { try {
@ -5474,11 +5472,16 @@ final class SyncEngine
// valid JSON object // valid JSON object
foreach (driveResult; siteDriveQuery["value"].array) { foreach (driveResult; siteDriveQuery["value"].array) {
// Display results // Display results
writeln("-----------------------------------------------");
log.vdebug("Site Details: ", driveResult);
found = true; found = true;
writeln("SiteName: ", searchResult["displayName"].str); writeln("Site Name: ", searchResult["displayName"].str);
writeln("drive_id: ", driveResult["id"].str); writeln("Library Name: ", driveResult["name"].str);
writeln("URL: ", webUrl); writeln("drive_id: ", driveResult["id"].str);
writeln("Library URL: ", driveResult["webUrl"].str);
} }
// closeout
writeln("-----------------------------------------------");
} else { } else {
// not a valid JSON object // not a valid JSON object
log.error("ERROR: There was an error performing this operation on OneDrive"); log.error("ERROR: There was an error performing this operation on OneDrive");
@ -5491,19 +5494,16 @@ final class SyncEngine
string siteNameAvailable = "Site 'name' was restricted by OneDrive API permissions"; string siteNameAvailable = "Site 'name' was restricted by OneDrive API permissions";
bool displayNameAvailable = false; bool displayNameAvailable = false;
bool idAvailable = false; bool idAvailable = false;
bool webUrlAvailable = false;
if ("name" in searchResult) siteNameAvailable = searchResult["name"].str; if ("name" in searchResult) siteNameAvailable = searchResult["name"].str;
if ("displayName" in searchResult) displayNameAvailable = true; if ("displayName" in searchResult) displayNameAvailable = true;
if ("id" in searchResult) idAvailable = true; if ("id" in searchResult) idAvailable = true;
if ("webUrl" in searchResult) webUrlAvailable = true;
// Display error details for this site data // Display error details for this site data
log.error("\nERROR: SharePoint Site details not provided for: ", siteNameAvailable); log.error("\nERROR: SharePoint Site details not provided for: ", siteNameAvailable);
log.error("ERROR: The SharePoint Site results returned from OneDrive API do not contain the required items to match. Please check your permissions with your site administrator."); log.error("ERROR: The SharePoint Site results returned from OneDrive API do not contain the required items to match. Please check your permissions with your site administrator.");
log.error("ERROR: Your site security settings is preventing the following details from being accessed: 'displayName', 'id' and 'webUrl'"); log.error("ERROR: Your site security settings is preventing the following details from being accessed: 'displayName' or 'id'");
log.vlog(" - Is 'displayName' available = ", displayNameAvailable); log.vlog(" - Is 'displayName' available = ", displayNameAvailable);
log.vlog(" - Is 'id' available = ", idAvailable); log.vlog(" - Is 'id' available = ", idAvailable);
log.vlog(" - Is 'webUrl' available = ", webUrlAvailable);
log.error("ERROR: To debug this further, please increase verbosity (--verbose or --verbose --verbose) to provide further insight as to what details are actually being returned."); log.error("ERROR: To debug this further, please increase verbosity (--verbose or --verbose --verbose) to provide further insight as to what details are actually being returned.");
} }
} }