summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-12-09 06:52:34 +0100
committerPierre Schmitz <pierre@archlinux.de>2010-12-09 06:52:34 +0100
commitc9d72df9e6cc51155306b30b2f23b2e4f58fdc05 (patch)
treed0c57afee613331a88714c57c453bf2159dbb43f
parentbff3dabaf45abbc7d6bed1b3ec1c717ae678c8b4 (diff)
downloaddbscripts-c9d72df9e6cc51155306b30b2f23b2e4f58fdc05.tar.gz
dbscripts-c9d72df9e6cc51155306b30b2f23b2e4f58fdc05.tar.xz
repo_lock: check if repo is locked by repo-add or repo-remove
-rw-r--r--db-functions7
1 files changed, 7 insertions, 0 deletions
diff --git a/db-functions b/db-functions
index cb76e7a..8ac9e63 100644
--- a/db-functions
+++ b/db-functions
@@ -135,12 +135,19 @@ trap cleanup EXIT
#repo_lock <repo-name> <arch> [timeout]
repo_lock () {
local LOCKDIR="$TMPDIR/.repolock.$1.$2"
+ local LOCKFILE="${FTP_BASE}/${1}/os/${2}/${1}${DBEXT}.lck"
local _count
local _trial
local _timeout
local _lockblock
local _owner
+ # This is the lock file used by repo-add and repo-remove
+ if [ -f "${LOCKFILE}" ]; then
+ error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat $LOCKFILE)"
+ return 1
+ fi
+
if [ $# -eq 2 ]; then
_lockblock=true
_trial=0