|
19 | 19 |
|
20 | 20 | import httpx |
21 | 21 |
|
22 | | -from .vendor.myutils import at_dir |
| 22 | +from .vendor.myutils import at_dir, file_lock |
23 | 23 | from .vendor.htmlutils import parse_document_from_httpx |
24 | 24 |
|
25 | 25 | from .cmd import git_pull, git_push, UNTRUSTED_PREFIX |
@@ -364,16 +364,18 @@ def _aur_exists(pkgbase: str) -> bool: |
364 | 364 | return r.status_code != 404 |
365 | 365 |
|
366 | 366 | def _ensure_aur_repo(pkgbase: str) -> Path: |
367 | | - aurpath = const.AUR_REPO_DIR / pkgbase |
368 | | - if not aurpath.is_dir(): |
369 | | - logger.info('cloning AUR repo: %s', aurpath) |
370 | | - with at_dir(const.AUR_REPO_DIR): |
371 | | - _run_cmd([ 'git', 'clone', f'[email protected]:{pkgbase}.git']) |
372 | | - else: |
373 | | - with at_dir(aurpath): |
374 | | - # reset everything, dropping local commits |
375 | | - _run_cmd(['git', 'reset', '--hard', 'origin/master']) |
376 | | - git_pull() |
| 367 | + lockfile = const.AUR_REPO_DIR / (pkgbase + '.lock') |
| 368 | + with file_lock(lockfile): |
| 369 | + aurpath = const.AUR_REPO_DIR / pkgbase |
| 370 | + if not aurpath.is_dir(): |
| 371 | + logger.info('cloning AUR repo: %s', aurpath) |
| 372 | + with at_dir(const.AUR_REPO_DIR): |
| 373 | + _run_cmd([ 'git', 'clone', f'[email protected]:{pkgbase}.git']) |
| 374 | + else: |
| 375 | + with at_dir(aurpath): |
| 376 | + # reset everything, dropping local commits |
| 377 | + _run_cmd(['git', 'reset', '--hard', 'origin/master']) |
| 378 | + git_pull() |
377 | 379 |
|
378 | 380 | return aurpath |
379 | 381 |
|
|
0 commit comments