From 2f3b7bc003087492fbae98768dd4ce25bde43539 Mon Sep 17 00:00:00 2001 From: MMA92 <25148407+MMA92@users.noreply.github.com> Date: Wed, 15 Jul 2026 20:52:58 +0200 Subject: [PATCH] Add lockfile for dnf check-update Implement locking mechanism for dnf update checks to prevent concurrent executions. --- .../ml4w/scripts/ml4w-check-system-updates | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dotfiles/.config/ml4w/scripts/ml4w-check-system-updates b/dotfiles/.config/ml4w/scripts/ml4w-check-system-updates index a32e1d59d..2bfbec442 100755 --- a/dotfiles/.config/ml4w/scripts/ml4w-check-system-updates +++ b/dotfiles/.config/ml4w/scripts/ml4w-check-system-updates @@ -69,7 +69,24 @@ if _checkCommandExists "pacman"; then # Fedora elif _checkCommandExists "dnf"; then - updates=$(dnf check-update -q | grep -c ^[a-z0-9]) + lockfile="${XDG_RUNTIME_DIR:-/tmp}/ml4w-dnf-check.lock" + + updates=$( + flock -n "$lockfile" bash -c ' + output=$(dnf check-update -q 2>/dev/null) + rc=$? + + # 0 = keine Updates, 100 = Updates vorhanden + if [ "$rc" -eq 0 ] || [ "$rc" -eq 100 ]; then + printf "%s\n" "$output" | awk "NF >= 3 { count++ } END { print count+0 }" + else + echo 0 + fi + ' + ) + + updates="${updates:-0}" + # Others else updates=0