Skip to content

Commit

Permalink
fix: onedrive: lastSyncTime returning null
Browse files Browse the repository at this point in the history
  • Loading branch information
amuwal committed Dec 20, 2024
1 parent 3fa218d commit 7c8e18e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 16 additions & 3 deletions packages/api/src/filestorage/file/services/onedrive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,29 @@ export class OnedriveService implements IFileService {
);
}

private async getLastSyncTime(connection: any) {
private async getLastSyncTime(connection: {
id_connection: string;
}): Promise<Date | null> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,12 @@ export class OnedriveService implements IFolderService {
private async getLastSyncTime(connectionId: string): Promise<Date | null> {
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;
}

Expand Down

0 comments on commit 7c8e18e

Please sign in to comment.