Skip to content

Commit 0d9a14e

Browse files
waleedlatif1claude
andcommitted
fix(uploads): fall through to INSERT if restore-deleted row races a hard delete
If a hard delete races between the initial SELECT and the restore UPDATE, .returning() yields no row. Previously the function would return undefined and silently violate the Promise<FileMetadataRecord> contract. Now the function falls through to the INSERT path, which already handles uniqueness races via the 23505 catch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent ffce93b commit 0d9a14e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

apps/sim/lib/uploads/server/metadata.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export async function insertFileMetadata(
5656
.where(eq(workspaceFiles.id, existingDeleted[0].id))
5757
.returning()
5858

59-
return restored
59+
if (restored) {
60+
return restored
61+
}
6062
}
6163

6264
const existing = await db

0 commit comments

Comments
 (0)