mirror of
https://github.com/mattintech/simplefileupload-server.git
synced 2026-07-11 10:41:54 +00:00
Fix race condition in chunked upload for parallel uploads
- Add BEGIN IMMEDIATE transaction to add_chunk() function - Prevents concurrent chunk uploads from overwriting each other - Fixes issue where parallel uploads would lose chunks in database - Critical for supporting 2+ parallel chunk uploads on mobile
This commit is contained in:
@@ -81,6 +81,9 @@ def add_chunk(upload_id, chunk_index):
|
|||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# Use IMMEDIATE transaction to prevent race conditions with parallel uploads
|
||||||
|
cursor.execute("BEGIN IMMEDIATE")
|
||||||
|
|
||||||
# Get current received_chunks
|
# Get current received_chunks
|
||||||
row = cursor.execute("""
|
row = cursor.execute("""
|
||||||
SELECT received_chunks FROM chunk_sessions WHERE upload_id = ?
|
SELECT received_chunks FROM chunk_sessions WHERE upload_id = ?
|
||||||
|
|||||||
Reference in New Issue
Block a user