From 49051dbca3a45165b4acd0edd466ca65740dc826 Mon Sep 17 00:00:00 2001 From: sbwml Date: Sat, 30 Mar 2024 20:56:51 +0800 Subject: [PATCH] luci-app-mosdns: remove lockfile when adlist download fail Signed-off-by: sbwml --- luci-app-mosdns/root/usr/share/mosdns/mosdns.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh index d725e4a..13320f2 100755 --- a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh +++ b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh @@ -56,7 +56,6 @@ adlist_update() { [ "$(uci -q get mosdns.config.adblock)" != 1 ] && return 0 lock_file=/var/lock/mosdns_ad_update.lock ad_source=$(uci -q get mosdns.config.ad_source) - AD_TMPDIR=$(mktemp -d) || exit 1 mirror="" : > /etc/mosdns/rule/.ad_source if [ -f "$lock_file" ]; then @@ -65,6 +64,7 @@ adlist_update() { else : > $lock_file fi + AD_TMPDIR=$(mktemp -d) || exit 1 has_update=0 for url in $ad_source; do @@ -81,7 +81,7 @@ adlist_update() { done if [ $? -ne 0 ]; then echo -e "\e[1;31mRules download failed.\e[0m" - rm -rf "$AD_TMPDIR" + rm -rf "$AD_TMPDIR" "$lock_file" exit 1 else [ $has_update -eq 1 ] && { @@ -90,7 +90,7 @@ adlist_update() { \cp $AD_TMPDIR/* /etc/mosdns/rule/adlist } fi - rm -rf "$AD_TMPDIR" $lock_file + rm -rf "$AD_TMPDIR" "$lock_file" } geodat_update() (