Update handling of --get-O365-drive-id for multi matching (#354)

* Update handling of --get-O365-drive-id to print out all 'site names' that match the explicit search entry rather than just the last match
* Add webUrl for site to output so that the 'right' site drive_id can be identified
* Update O365 readme with updated output
This commit is contained in:
abraunegg 2019-01-19 13:01:41 +11:00 committed by GitHub
parent c27ff936fb
commit 7532c9d8cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

@ -8,8 +8,10 @@ onedrive --get-O365-drive-id '<your library name>'
3. This will return the following:
```bash
Initializing the Synchronization Engine ...
Office 365 Library Name: ab-github-odtest
drive_id: b!6H.....l7vVxU5
Office 365 Library Name Query: <your library name>
SiteName: <your library name>
drive_id: b!6H_y8B...xU5
URL: <your site URL>
```
## Configuring the onedrive client

View file

@ -1924,24 +1924,30 @@ final class SyncEngine
string site_id;
string drive_id;
string webUrl;
bool found = false;
JSONValue siteQuery = onedrive.o365SiteSearch(encodeComponent(o365SharedLibraryName));
log.log("Office 365 Library Name Query: ", o365SharedLibraryName);
foreach (searchResult; siteQuery["value"].array) {
// Need an 'exclusive' match here with o365SharedLibraryName as entered
if (o365SharedLibraryName == searchResult["displayName"].str){
// 'displayName' matches search request
site_id = searchResult["id"].str;
webUrl = searchResult["webUrl"].str;
JSONValue siteDriveQuery = onedrive.o365SiteDrives(site_id);
foreach (driveResult; siteDriveQuery["value"].array) {
drive_id = driveResult["id"].str;
// Display results
found = true;
writeln("SiteName: ", searchResult["displayName"].str);
writeln("drive_id: ", driveResult["id"].str);
writeln("URL: ", webUrl);
}
}
}
log.log("Office 365 Library Name: ", o365SharedLibraryName);
if(drive_id != null) {
log.log("drive_id: ", drive_id);
} else {
if(!found) {
writeln("ERROR: This site could not be found. Please check it's name and your permissions to access the site.");
}
}