Skip to content

Commit 7c8e18e

Browse files
committed
fix: onedrive: lastSyncTime returning null
1 parent 3fa218d commit 7c8e18e

File tree

2 files changed

+21
-4
lines changed
  • packages/api/src/filestorage

2 files changed

+21
-4
lines changed

Diff for: packages/api/src/filestorage/file/services/onedrive/index.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,29 @@ export class OnedriveService implements IFileService {
258258
);
259259
}
260260

261-
private async getLastSyncTime(connection: any) {
261+
private async getLastSyncTime(connection: {
262+
id_connection: string;
263+
}): Promise<Date | null> {
262264
const lastSyncTime = await this.prisma.fs_files.findFirst({
263265
where: {
264266
id_connection: connection.id_connection,
265267
},
266268
orderBy: {
267-
remote_modified_at: 'desc',
269+
remote_modified_at: {
270+
sort: 'desc',
271+
nulls: 'last',
272+
},
273+
},
274+
select: {
275+
remote_modified_at: true,
268276
},
269277
});
270-
return lastSyncTime?.remote_modified_at;
278+
279+
this.logger.log(
280+
`Last file sync time: ${lastSyncTime?.remote_modified_at}`,
281+
'onedrive files sync',
282+
);
283+
return lastSyncTime?.remote_modified_at ?? null;
271284
}
272285

273286
private async syncFolder(

Diff for: packages/api/src/filestorage/folder/services/onedrive/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,12 @@ export class OnedriveService implements IFolderService {
715715
private async getLastSyncTime(connectionId: string): Promise<Date | null> {
716716
const lastSync = await this.prisma.fs_folders.findFirst({
717717
where: { id_connection: connectionId },
718-
orderBy: { remote_modified_at: 'desc' },
718+
orderBy: { remote_modified_at: { sort: 'desc', nulls: 'last' } },
719719
});
720+
this.logger.log(
721+
`Last sync time: ${lastSync?.remote_modified_at}`,
722+
'onedrive folders sync',
723+
);
720724
return lastSync ? lastSync.remote_modified_at : null;
721725
}
722726

0 commit comments

Comments
 (0)