Never notify about pending migrations during an update
The retired omarchy-update-user-notify.path stays loaded in sessions that started before the update removing it, and pacman writes the migrations directory mid-transaction, so it fired a critical toast for migrations that omarchy-migrate was about to apply a step later. Migration 1785095882 stops that watcher, but migrations run after pacman, so it lands 11 seconds too late to prevent the toast it exists to retire. Check the lock omarchy-update holds for its whole pipeline instead of trusting that no trigger exists. That covers the stale watcher and anything added later: during an update every pending migration is by definition already being applied. The check repeats after waiting for the notification server, which is long enough for an update to start underneath it. Only this user's runtime directory is read, never the /tmp path the updater falls back to without XDG_RUNTIME_DIR. A shared lock file belongs to whoever created it first, so honouring it would let one user silence another user's notification; a redundant toast is the better failure. The sleep inhibitor now starts with the lock descriptor closed. It outlives the step that starts it, so an update killed before restore_update_inhibitors left it holding the flock indefinitely. That already blocked later updates, and now that the notifier reads the same lock it would have silenced migration notices at every login. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
4d93ad588f
commit
03902f2460
@@ -4,6 +4,19 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
update_in_progress() {
|
||||
local lock="${XDG_RUNTIME_DIR:-}/omarchy-update.lock"
|
||||
|
||||
[[ -n ${XDG_RUNTIME_DIR:-} && -f $lock ]] || return 1
|
||||
|
||||
# flock -n only fails here when the lock is held, since the file is ours.
|
||||
! flock -n "$lock" true 2>/dev/null
|
||||
}
|
||||
|
||||
if update_in_progress; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
pending_migrations=$(omarchy-migrate --pending 2>/dev/null) || exit 0
|
||||
pending_count=$(printf '%s\n' "$pending_migrations" | sed '/^[[:space:]]*$/d' | wc -l)
|
||||
|
||||
@@ -21,6 +34,12 @@ notify_command=$(printf 'if [[ -n $(omarchy-notification-send -u critical -g
|
||||
# void and the user never learns about their pending migrations.
|
||||
omarchy-notification-wait || true
|
||||
|
||||
# That wait is long enough for an update to start underneath us, and the count
|
||||
# above is already stale by then, so re-check before spending the toast.
|
||||
if update_in_progress; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
unit="omarchy-migrations-notification-$(date +%Y%m%d%H%M%S)"
|
||||
systemd-run --user --scope --unit="$unit" bash -lc "$notify_command" >/dev/null 2>&1 && exit 0
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ disable_sleep_for_update() {
|
||||
--who=omarchy-update \
|
||||
--why="Omarchy update in progress" \
|
||||
--mode=block \
|
||||
sleep infinity >/dev/null 2>&1 &
|
||||
sleep infinity >/dev/null 2>&1 {OMARCHY_UPDATE_LOCK_FD}>&- &
|
||||
sleep_inhibit_pid=$!
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user