Skip to content

Commit 6d2f62a

Browse files
fix(tables): delete the uploaded CSV from storage after the import finishes
1 parent 1a20d57 commit 6d2f62a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

apps/sim/lib/table/import-runner.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
setTableSchemaForImport,
2828
updateImportProgress,
2929
} from '@/lib/table/service'
30-
import { downloadFileStream, headObject } from '@/lib/uploads/core/storage-service'
30+
import { deleteFile, downloadFileStream, headObject } from '@/lib/uploads/core/storage-service'
3131
import { normalizeColumn } from '@/app/api/table/utils'
3232

3333
const logger = createLogger('TableImportRunner')
@@ -251,5 +251,11 @@ export async function runTableImport(payload: TableImportPayload): Promise<void>
251251
logger.error(`[${requestId}] Import failed for table ${tableId}:`, err)
252252
await markImportFailed(tableId, message).catch(() => {})
253253
void appendTableEvent({ kind: 'import', tableId, importId, status: 'failed', error: message })
254+
} finally {
255+
// The uploaded source file is single-use (a fresh upload per import) — delete it once the
256+
// import is terminal so the workspace bucket doesn't accumulate. Best-effort.
257+
await deleteFile({ key: fileKey, context: 'workspace' }).catch((err) => {
258+
logger.warn(`[${requestId}] Failed to delete imported file`, { fileKey, err })
259+
})
254260
}
255261
}

0 commit comments

Comments
 (0)