summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-07-27 17:49:28 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-07-27 17:49:28 (EDT)
commitb8fb9e8ae492c1d19a9c084a2469dc09c026e072 (patch)
treece85124bfe3a5a2730adaea9b521a606ef91f8a1 /lib
parent66e122128bd7d54e59a9992613769a68c4469d5a (diff)
lib/db.sh: Make functions more robust.
Diffstat (limited to 'lib')
-rw-r--r--lib/db.sh20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/db.sh b/lib/db.sh
index 7533126..27a1ae8 100644
--- a/lib/db.sh
+++ b/lib/db.sh
@@ -139,6 +139,9 @@ db_get_archplats()
dir="${opt_base_dir}/feeds/${chan}/${dist}/.db"
dir="${dir}/$(hash_name "${source}")/${source}"
for dir in "${dir}/"*_*/; do
+ if [ ! -d "${dir}" ]; then
+ continue
+ fi
dir="${dir%/}"
dir="${dir##*/}"
printf '%s %s\n' "${dir%%_*}" "${dir#*_}"
@@ -216,8 +219,13 @@ db_inc_references()
dir="${opt_base_dir}/pool/$(hash_name "${source}")/${source}/.db"
dir="${dir}/${binver}_${arch}_${plat}"
- refs="$(cat "${dir}/references")"
- refs=$(($refs + 1))
+ if [ -f "${dir}/references" ]; then
+ refs="$(cat "${dir}/references")"
+ refs=$(($refs + 1))
+ else
+ refs=1
+ mkdir -p "${dir}"
+ fi
printf '%d\n' "${refs}" >"${dir}/references"
printf '%d\n' "${refs}"
@@ -235,8 +243,12 @@ db_dec_references()
dir="${opt_base_dir}/pool/$(hash_name "${source}")/${source}/.db"
dir="${dir}/${binver}_${arch}_${plat}"
- refs="$(cat "${dir}/references")"
- refs=$(($refs - 1))
+ if [ -f "${dir}/references" ]; then
+ refs="$(cat "${dir}/references")"
+ refs=$(($refs - 1))
+ else
+ refs=0
+ fi
if [ ${refs} -eq 0 ]; then
rm -f "${dir}/references"
else