From 6129eff668c8ff45d5ae34c12169eeef817ec00f Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Sun, 3 Jan 2016 07:14:57 +0000 Subject: [PATCH] Avoid concurrent downloads of the same package --- scripts/get | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/get b/scripts/get index a53ee4c5b6..487f9b4d3c 100755 --- a/scripts/get +++ b/scripts/get @@ -28,6 +28,16 @@ if [ -z "$1" ]; then fi if [ -n "$PKG_URL" ]; then + mkdir -p $SOURCES/$1 + + # Avoid concurrent downloads of the same package + _isblocked=N + exec 99>$SOURCES/$1/.lock + while ! flock --nonblock --exclusive 99; do + [ ${_isblocked} == N ] && { echo "Project ${PROJECT} waiting to avoid concurrent download of ${1}..."; _isblocked=Y; } + sleep 1 + done + for i in $PKG_URL; do SOURCE_NAME="`basename $i`" PACKAGE="$SOURCES/$1/$SOURCE_NAME" @@ -40,8 +50,6 @@ if [ -n "$PKG_URL" ]; then STAMP="$PACKAGE.url" MD5SUM="$PACKAGE.md5" - mkdir -p $SOURCES/$1 - if [ -f "$STAMP" ]; then [ "`cat $STAMP`" = "$i" ] && continue fi