Skip to content

Commit

Permalink
Fix filtering of deleted synced sheets (#4210)
Browse files Browse the repository at this point in the history
* Handle Sheet with gid = 0

* Fix log
  • Loading branch information
flvndvd authored Mar 7, 2024
1 parent 452e40e commit 50680ba
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions connectors/src/connectors/google_drive/temporal/spreadsheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export async function syncSpreadSheet(
// List synced sheets.
const syncedSheets = await GoogleDriveSheet.findAll({
where: {
connectorId: connector.id,
driveFileId: file.id,
},
});
Expand All @@ -451,9 +452,11 @@ export async function syncSpreadSheet(
// or have exceeded the maximum number of rows.
const deletedSyncedSheets = syncedSheets.filter(
(synced) =>
!successfulSheetIdImports.find(
// Check for undefined explicitly, avoiding incorrect filtering
// due to falsy values (0 can be a valid sheet ID).
successfulSheetIdImports.find(
(sheetId) => sheetId === synced.driveSheetId
)
) === undefined
);
if (deletedSyncedSheets.length > 0) {
await deleteAllSheets(connector, deletedSyncedSheets, {
Expand All @@ -475,7 +478,9 @@ async function deleteSheetForSpreadsheet(
{
connectorId: connector.id,
sheet,
spreadsheetFileId,
spreadsheet: {
id: spreadsheetFileId,
},
},
"[Spreadsheet] Deleting google drive sheet."
);
Expand Down

0 comments on commit 50680ba

Please sign in to comment.