diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/db.sh | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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 |