Skip to content

fix(firestore): prevent double database write on file rename upload#72

Open
vibhutomer wants to merge 1 commit into
seetadev:mainfrom
vibhutomer:fix/upload-double-write
Open

fix(firestore): prevent double database write on file rename upload#72
vibhutomer wants to merge 1 commit into
seetadev:mainfrom
vibhutomer:fix/upload-double-write

Conversation

@vibhutomer
Copy link
Copy Markdown

Fix: Prevent Double-Write Quota Drain in Cloud Uploads

Related Issue

Description of Changes

  • Fixed a control-flow bug in the uploadFileToCloud function (firestore.ts).
  • When resolving a duplicate filename, the code previously saved the new file but fell through to execute a second setDoc operation.
  • Added if (onSuccess) onSuccess(); and a return; statement immediately after the conflict-resolution upload.

Impact

  • Cost Optimization: Cuts Firebase database writes in half when users resolve naming conflicts.
  • Network Stability: Prevents concurrent duplicate POST requests to the backend.
  • Bug Prevention: Stops the onSuccess callback from firing twice, which could cause erratic UI behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double Database Write on Duplicate File Upload

1 participant