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:
+3
-2
@@ -31,8 +31,7 @@ notify_once() {
|
||||
if [[ -f $file && $(<"$file") == "$body" ]]; then
|
||||
return 0
|
||||
fi
|
||||
printf '%s' "$body" > "$file"
|
||||
notify-send "$title" "$body"
|
||||
notify-send "$title" "$body" && printf '%s' "$body" > "$file"
|
||||
}
|
||||
|
||||
# Forget a key so the next occurrence notifies again.
|
||||
@@ -75,7 +74,9 @@ latest_version() {
|
||||
checkupdates_out=$(checkupdates 2>/dev/null)
|
||||
checkupdates_rc=$?
|
||||
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
|
||||
exit 1
|
||||
fi
|
||||
|
||||
arch_list=()
|
||||
|
||||
Reference in New Issue
Block a user