1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-21 23:17:42 +02:00

All: Resolves #1266: Add support for OneDrive for Business (#3433)

This commit is contained in:
jonath92
2020-08-08 01:35:30 +02:00
committed by GitHub
parent aa147bbcdc
commit 799a9e810d
4 changed files with 56 additions and 28 deletions

View File

@ -217,7 +217,9 @@ class FileApiDriverOneDrive {
};
const freshStartDelta = () => {
const url = `${this.makePath_(path)}:/delta`;
// Business Accounts are only allowed to make delta requests to the root. For some reason /delta gives an error for personal accounts and :/delta an error for business accounts
const accountProperties = this.api_.accountProperties_;
const url = (accountProperties.accountType === 'business') ? `/drives/${accountProperties.driveId}/root/delta` : `${this.makePath_(path)}:/delta`;
const query = this.itemFilter_();
query.select += ',deleted';
return { url: url, query: query };
@ -265,14 +267,14 @@ class FileApiDriverOneDrive {
const items = [];
// The delta API might return things that happen in subdirectories of the root and we don't want to
// deal with these since all the files we're interested in are at the root (The .resource dir
// is special since it's managed directly by the clients and resources never change - only the
// associated .md file at the root is synced). So in the loop below we check that the parent is
// indeed the root, otherwise the item is skipped.
// (Not sure but it's possible the delta API also returns events for files that are copied outside
// of the app directory and later deleted or modified. We also don't want to deal with
// these files during sync).
// The delta API might return things that happens in subdirectories and outside of the joplin directory.
// We don't want to deal with these since all the files we're interested in are at the root of the joplin directory
// (The .resource dir is special since it's managed directly by the clients and resources never change - only the
// associated .md file at the root is synced). So in the loop below we check that the parent is indeed the joplin
// directory, otherwise the item is skipped.
// At OneDrive for Business delta requests can only make at the root of OneDrive. Not sure but it's possible that
// the delta API also returns events for files that are copied outside of the app directory and later deleted or
// modified when using OneDrive Personal).
for (let i = 0; i < response.value.length; i++) {
const v = response.value[i];