Skip to content

Commit

Permalink
Merge pull request #703 from amuwal/fix-sync-onedrive/sharepoint
Browse files Browse the repository at this point in the history
Consider drive root to be a folder when syncing onedrive/sharepoint
  • Loading branch information
naelob authored Sep 20, 2024
2 parents d591aff + 7ae8489 commit a12f389
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
15 changes: 14 additions & 1 deletion packages/api/src/filestorage/folder/services/onedrive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@ export class OnedriveService implements IFolderService {
},
});

let result = [],
// get root folder
const rootFolderData = await axios.get(
`${connection.account_url}/v1.0/me/drive/root`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.cryptoService.decrypt(
connection.access_token,
)}`,
},
},
);

let result = [rootFolderData.data],
depth = 0,
batch = [remote_folder_id];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export interface OnedriveFolderInput {
readonly createdBy?: IdentitySet;
/** Identity of the user, device, and application that last modified the item. Read-only. */
readonly lastModifiedBy?: IdentitySet;
/** If this property is non-null, it indicates that the driveItem is the top-most driveItem in the drive. */
readonly root?: any;
}

/**
Expand Down
17 changes: 15 additions & 2 deletions packages/api/src/filestorage/folder/services/sharepoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ export class SharepointService implements IFolderService {
},
});

let result = [],
// get root folder
const rootFolderData = await axios.get(
`${connection.account_url}/drive/root`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.cryptoService.decrypt(
connection.access_token,
)}`,
},
},
);

let result = [rootFolderData.data],
depth = 0,
batch = [remote_folder_id];

Expand All @@ -104,7 +117,7 @@ export class SharepointService implements IFolderService {
},
);

// Add permissions (shared link is also included in permissions in one-drive)
// Add permissions (shared link is also included in permissions in SharePoint)
// await Promise.all(
// resp.data.value.map(async (driveItem) => {
// const resp = await axios.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export interface SharepointFolderInput {
readonly createdBy?: IdentitySet;
/** Identity of the user, device, and application that last modified the item. Read-only. */
readonly lastModifiedBy?: IdentitySet;
/** If this property is non-null, it indicates that the driveItem is the top-most driveItem in the drive. */
readonly root?: any;
}

/**
Expand Down

0 comments on commit a12f389

Please sign in to comment.