dir-not-empty function

This commit is contained in:
bigeagle 2016-11-20 16:49:13 +08:00
parent f146cf65a2
commit 7fca77ec9f
2 changed files with 13 additions and 3 deletions

View File

@ -161,9 +161,9 @@ function apt-download-binary() {
[[ $downloaded == false ]] && ERROR=1
done
mv ${pkgidx_tmp_dir}/* ${pkgidx_dir}
mv ${comp_tmp_dir}/* ${comp_dir}
mv ${dist_tmp_dir}/* ${dist_dir}
dir-not-empty ${pkgidx_tmp_dir} && mv ${pkgidx_tmp_dir}/* ${pkgidx_dir}
dir-not-empty ${dist_tmp_dir} && mv ${dist_tmp_dir}/* ${dist_dir}
dir-not-empty ${comp_tmp_dir} && mv ${comp_tmp_dir}/* ${comp_dir}
rmdir ${pkgidx_tmp_dir} ${dist_tmp_dir} ${comp_tmp_dir}

View File

@ -13,5 +13,15 @@ function check-and-download() {
return
}
function dir-not-empty() {
local dir=$1
[[ ! -d "$dir" ]] && return 1
nfiles=$(ls -a "$dir" | wc -l)
if (( ${nfiles} > 2 )); then
return 0
fi
return 1
}
LOADED_HELPERS="yes"