mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-29 15:15:27 -07:00
fix: prevent intermittent clip splitting failures (#403)
Two changes to address the race condition causing "Failed to split clip": Backend (stories.py): Added with_for_update() to the item query in split_story_item so concurrent requests for the same clip are serialized via a row lock instead of racing. Frontend (StoryTrackEditor.tsx): Guard handleSplit with splitItem.isPending to prevent rapid double-clicks from firing multiple mutations before the first completes. Fixes #366 Co-authored-by: Matt Van Horn <[email protected]>
This commit is contained in:
co-authored by
Matt Van Horn
parent
9a3c307c75
commit
13ba5f1aa6
@@ -484,13 +484,15 @@ async def split_story_item(
|
||||
Returns:
|
||||
List of two updated item details (original and new) or None if not found/invalid
|
||||
"""
|
||||
# Get the item
|
||||
# Get the item with a row lock to prevent concurrent splits on the
|
||||
# same clip (e.g. from rapid double-clicks racing each other).
|
||||
item = (
|
||||
db.query(DBStoryItem)
|
||||
.filter_by(
|
||||
id=item_id,
|
||||
story_id=story_id,
|
||||
)
|
||||
.with_for_update()
|
||||
.first()
|
||||
)
|
||||
if not item:
|
||||
|
||||
Reference in New Issue
Block a user