repo-add: ensure path to LOCKFILE is always absolute

Given our semi-frequent use of pushd/popd, if we are in any directory
but the original and the database path given was relative, we won't
unlock the database file when cleaning up after an error.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-11-15 22:16:41 -06:00
parent 2752932d19
commit 6a9ed33055
1 changed files with 7 additions and 8 deletions

View File

@ -411,13 +411,8 @@ elephant() {
check_repo_db() {
local repodir
# ensure the path to the DB exists
if [[ "$LOCKFILE" == /* ]]; then
repodir=${LOCKFILE%/*}/
else
repodir=$PWD/$LOCKFILE
repodir=${repodir%/*}/
fi
# ensure the path to the DB exists; $LOCKFILE is always an absolute path
repodir=${LOCKFILE%/*}/
if [[ ! -d "$repodir" ]]; then
error "$(gettext "%s does not exist or is not a directory.")" "$repodir"
@ -624,7 +619,11 @@ if [[ -z $REPO_DB_FILE ]]; then
exit 1
fi
LOCKFILE=$REPO_DB_FILE.lck
if [[ $REPO_DB_FILE == /* ]]; then
LOCKFILE=$REPO_DB_FILE.lck
else
LOCKFILE=$PWD/$REPO_DB_FILE.lck
fi
verify_repo_extension "$REPO_DB_FILE" >/dev/null
check_repo_db