Skip to content

Commit 576ce52

Browse files
authored
minor: fix image upload cleanup refs (#3228)
A small bug the robot caught while looking at #3222. At the end of a successful image upload, we delete the temporary snapshot and disk. If snapshot deletion succeeded but disk deletion failed, the catch path called `cleanup()` while `snapshot.current` still pointed at the already-deleted snapshot. Cleanup would then try to delete that snapshot again, fail with 404, and never reach the remaining disk cleanup. Fix: Clear each ref immediately after its successful delete so later cleanup only retries resources that still exist. It would be nice to have a test for this but it would be pretty elaborate for little gain.
1 parent 337b4e8 commit 576ce52

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

app/forms/image-upload.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@ export default function ImageCreate() {
508508
// now delete the snapshot and the disk. don't use cleanup() because that
509509
// uses different mutations
510510
await deleteSnapshot.mutateAsync({ path: { snapshot: snapshot.current.id } })
511+
snapshot.current = null
511512
await deleteDisk.mutateAsync({ path: { disk: disk.current.id } })
513+
disk.current = null
512514

513515
setAllDone(true)
514516
}

0 commit comments

Comments
 (0)