Skip to content

Commit 62589a1

Browse files
bazilinskyyclaude
andcommitted
Review hub: Merge holds mapping-pavlo.csv's lock while it reads and overwrites it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2b8a771 commit 62589a1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎review_hub.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
"Push the mapping" commits mapping.csv as it is here onto GitHub's main and pushes it.
1111
"""
12+
import contextlib
1213
import io
1314
import json
1415
import os
@@ -678,11 +679,13 @@ def merge_mapping_files():
678679
the same locality, state and country, else as a new row; a video the mapping has stays as it is here. Then each
679680
mapping-NAME.csv becomes a copy of the merged mapping (user, 2026-10-11) and all are pushed in one commit.
680681
Returns a message."""
681-
with ps.plan_lock(add_video.FILE_PATH):
682+
local = [n for n in LOCAL_MAPPINGS if os.path.exists(n)]
683+
with ps.plan_lock(add_video.FILE_PATH), contextlib.ExitStack() as held:
684+
for n in local: # the add_video form saves under the same lock (add_video.mapping_lock)
685+
held.enter_context(ps.plan_lock(n))
682686
git('fetch', '-q', 'origin', 'main')
683687
names = [n for n in git('ls-tree', '--name-only', 'origin/main').split()
684688
if re.fullmatch(r'mapping-[^/]+\.csv', n)]
685-
local = [n for n in LOCAL_MAPPINGS if os.path.exists(n)]
686689
names += [n for n in local if n not in names]
687690
df = add_video.load_csv(add_video.FILE_PATH)
688691
have = {v for cell in df['videos'] for v in add_video._parse_flat_list_cell(cell)}

0 commit comments

Comments
 (0)