From cdd41b166a9b5d7f35ac2d6d5cc27bc9c9e4a534 Mon Sep 17 00:00:00 2001 From: amit <1mitccc@gmail.com> Date: Mon, 23 Dec 2024 09:30:49 +0530 Subject: [PATCH] fix: googledrive: handle edge case for empty changes with changes API --- .../src/filestorage/file/services/googledrive/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/api/src/filestorage/file/services/googledrive/index.ts b/packages/api/src/filestorage/file/services/googledrive/index.ts index c47f00621..2f76395bc 100644 --- a/packages/api/src/filestorage/file/services/googledrive/index.ts +++ b/packages/api/src/filestorage/file/services/googledrive/index.ts @@ -287,10 +287,16 @@ export class GoogleDriveService implements IFileService { // Update pageToken for next iteration pageToken = nextPageToken; + newRemoteCursor = newStartPageToken || nextPageToken; apiCallCount++; - if (!nextPageToken || apiCallCount >= maxApiCalls) { - newRemoteCursor = newStartPageToken || nextPageToken; + if (nextPageToken && changes.length === 0) { + // edge case where we have no changes but still have a nextPageToken + return { + filesToSync, + moreChangesToFetch: false, + remote_cursor: newRemoteCursor, + }; } } while (pageToken && apiCallCount < maxApiCalls);