Properly clean up the working directory

This commit is contained in:
Howard20181 2023-01-03 18:04:05 +08:00
parent b5c995ad2c
commit f9a8b78ed5

View file

@ -38,6 +38,8 @@ SUDO="$(which sudo 2>/dev/null)"
if [ -z "$SUDO" ]; then if [ -z "$SUDO" ]; then
unset SUDO unset SUDO
fi fi
DOWNLOAD_DIR=../download
DOWNLOAD_CONF_NAME=download.list
umount_clean() { umount_clean() {
echo "Cleanup Work Directory" echo "Cleanup Work Directory"
if [ -d "$MOUNT_DIR" ]; then if [ -d "$MOUNT_DIR" ]; then
@ -60,10 +62,9 @@ umount_clean() {
rm -rf "${TMPDIR:?}" rm -rf "${TMPDIR:?}"
unset TMPDIR unset TMPDIR
fi fi
rm -f "${DOWNLOAD_DIR:?}/$DOWNLOAD_CONF_NAME"
} }
trap umount_clean EXIT trap umount_clean EXIT
DOWNLOAD_DIR=../download
DOWNLOAD_CONF_NAME=download.list
OUTPUT_DIR=../output OUTPUT_DIR=../output
WSA_WORK_ENV="${WORK_DIR:?}"/ENV WSA_WORK_ENV="${WORK_DIR:?}"/ENV
if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi
@ -366,7 +367,6 @@ update_gapps_zip_name() {
} }
update_gapps_zip_name update_gapps_zip_name
if [ -z "${OFFLINE+x}" ]; then if [ -z "${OFFLINE+x}" ]; then
trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT
require_su require_su
if [ "${DOWN_WSA}" != "no" ]; then if [ "${DOWN_WSA}" != "no" ]; then
echo "Generate Download Links" echo "Generate Download Links"