diff --git a/packages/api/src/filestorage/file/services/onedrive/index.ts b/packages/api/src/filestorage/file/services/onedrive/index.ts index 3895ed570..5394a14a8 100644 --- a/packages/api/src/filestorage/file/services/onedrive/index.ts +++ b/packages/api/src/filestorage/file/services/onedrive/index.ts @@ -29,7 +29,6 @@ export class OnedriveService implements IFileService { async sync(data: SyncParam): Promise> { try { const { linkedUserId, id_folder } = data; - if (!id_folder) return; const connection = await this.prisma.connections.findFirst({ where: { @@ -39,11 +38,15 @@ export class OnedriveService implements IFileService { }, }); - const folder = await this.prisma.fs_folders.findUnique({ - where: { - id_fs_folder: id_folder as string, - }, - }); + const folder = id_folder + ? await this.prisma.fs_folders.findUnique({ + where: { + id_fs_folder: id_folder as string, + }, + }) + : { + remote_id: 'root', + }; const resp = await axios.get( `${connection.account_url}/v1.0/drive/items/${folder.remote_id}/children`, diff --git a/packages/api/src/filestorage/file/services/sharepoint/index.ts b/packages/api/src/filestorage/file/services/sharepoint/index.ts index 44d5bc8a7..27027b315 100644 --- a/packages/api/src/filestorage/file/services/sharepoint/index.ts +++ b/packages/api/src/filestorage/file/services/sharepoint/index.ts @@ -29,7 +29,6 @@ export class SharepointService implements IFileService { async sync(data: SyncParam): Promise> { try { const { linkedUserId, id_folder } = data; - if (!id_folder) return; const connection = await this.prisma.connections.findFirst({ where: { @@ -39,11 +38,15 @@ export class SharepointService implements IFileService { }, }); - const folder = await this.prisma.fs_folders.findUnique({ - where: { - id_fs_folder: id_folder as string, - }, - }); + const folder = id_folder + ? await this.prisma.fs_folders.findUnique({ + where: { + id_fs_folder: id_folder as string, + }, + }) + : { + remote_id: 'root', + }; const resp = await axios.get( `${connection.account_url}/drive/items/${folder.remote_id}/children`,