diff --git a/packages/api/src/filestorage/file/services/onedrive/index.ts b/packages/api/src/filestorage/file/services/onedrive/index.ts index 4b26c7876..52f2c270a 100644 --- a/packages/api/src/filestorage/file/services/onedrive/index.ts +++ b/packages/api/src/filestorage/file/services/onedrive/index.ts @@ -258,16 +258,29 @@ export class OnedriveService implements IFileService { ); } - private async getLastSyncTime(connection: any) { + private async getLastSyncTime(connection: { + id_connection: string; + }): Promise { const lastSyncTime = await this.prisma.fs_files.findFirst({ where: { id_connection: connection.id_connection, }, orderBy: { - remote_modified_at: 'desc', + remote_modified_at: { + sort: 'desc', + nulls: 'last', + }, + }, + select: { + remote_modified_at: true, }, }); - return lastSyncTime?.remote_modified_at; + + this.logger.log( + `Last file sync time: ${lastSyncTime?.remote_modified_at}`, + 'onedrive files sync', + ); + return lastSyncTime?.remote_modified_at ?? null; } private async syncFolder( diff --git a/packages/api/src/filestorage/folder/services/onedrive/index.ts b/packages/api/src/filestorage/folder/services/onedrive/index.ts index c029f3ecf..c9f2cd32c 100644 --- a/packages/api/src/filestorage/folder/services/onedrive/index.ts +++ b/packages/api/src/filestorage/folder/services/onedrive/index.ts @@ -715,8 +715,12 @@ export class OnedriveService implements IFolderService { private async getLastSyncTime(connectionId: string): Promise { const lastSync = await this.prisma.fs_folders.findFirst({ where: { id_connection: connectionId }, - orderBy: { remote_modified_at: 'desc' }, + orderBy: { remote_modified_at: { sort: 'desc', nulls: 'last' } }, }); + this.logger.log( + `Last sync time: ${lastSync?.remote_modified_at}`, + 'onedrive folders sync', + ); return lastSync ? lastSync.remote_modified_at : null; }