diff --git a/lib/aur-fetch b/lib/aur-fetch index c569d4f2..8207489f 100755 --- a/lib/aur-fetch +++ b/lib/aur-fetch @@ -119,6 +119,7 @@ if (( ! $# )); then exit 1 fi +# XXX: race with concurrent processes if [[ -v results_file ]]; then : >"$results_file" || exit 1 # truncate file fi @@ -160,6 +161,10 @@ for pkg in "${packages[@]}"; do continue elif [[ -d $pkg/.git ]]; then + # Per-package lock + exec {fd}< "$pkg"/.git + flock --wait 5 "$fd" || exit 1 + # Avoid issues with filesystem boundaries (#274) git() { command git -C "$pkg" "$@"; } @@ -213,6 +218,7 @@ for pkg in "${packages[@]}"; do if [[ -v results_file ]]; then results "$sync_pkg" "$orig_head" "$head" "$PWD/$pkg" "$results_file" fi + exec {fd}<&- # release lock # Otherwise, try to clone anew else