fetch: use per-package locks for destructive operations

pull/1017/head
Alad Wenter 2 months ago
parent 286d6c800f
commit aaf7319b5f
  1. 6
      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

Loading…
Cancel
Save