Avoid lost and repeated notifications

Exit without touching the state when checkupdates fails, so a transient
error no longer clears it and causes the same notification on the next
run. Also save the state only after notify-send succeeds, so a failed
notification is retried.
This commit is contained in:
Daniele Fucini
2026-10-07 19:45:38 +02:00
parent e674f0311c
commit dbb7a1766d
+3 -2
View File
@@ -31,8 +31,7 @@ notify_once() {
if [[ -f $file && $(<"$file") == "$body" ]]; then if [[ -f $file && $(<"$file") == "$body" ]]; then
return 0 return 0
fi fi
printf '%s' "$body" > "$file" notify-send "$title" "$body" && printf '%s' "$body" > "$file"
notify-send "$title" "$body"
} }
# Forget a key so the next occurrence notifies again. # Forget a key so the next occurrence notifies again.
@@ -75,7 +74,9 @@ latest_version() {
checkupdates_out=$(checkupdates 2>/dev/null) checkupdates_out=$(checkupdates 2>/dev/null)
checkupdates_rc=$? checkupdates_rc=$?
if (( checkupdates_rc == 1 )); then if (( checkupdates_rc == 1 )); then
# Bail out without touching the state, so the next good run doesn't re-notify
echo "checkupdates failed (network or sync problem?)" >&2 echo "checkupdates failed (network or sync problem?)" >&2
exit 1
fi fi
arch_list=() arch_list=()