fix(movetdarr.sh): BusyBox flock hat kein -w (timeout) → -n + Retry-Loop

BusyBox flock kennt nur -n (non-blocking), nicht -w/--timeout.
Der alte Code 'flock -w 900' schlug fehl → Skript fiel sofort in
'fahre ohne Lock fort' und lief ohne Race-Schutz.

Fix: -n mit 900s Retry-Loop (1s Intervall) = effektiv 15min Timeout.
Der Lock wird jettt korrekt gesetzt, parallele Downloads sind serialisiert.
This commit is contained in:
sascha 2026-09-06 10:10:37 +02:00
parent e8a36502e9
commit bb748741cd

View file

@ -145,14 +145,19 @@ register_lease() {
}
if command -v flock >/dev/null 2>&1; then
flock -w 900 "$LEASE_LOCK" -c 'set -e' || true # Lock-Datei anlegen
exec 9>"$LEASE_LOCK"
if ! flock -w 900 9; then
log "WARNUNG: Lease-Lock nach 15 Minuten nicht erhalten; fahre ohne Lock fort"
register_lease
else
register_lease
# BusyBox flock hat kein -w (timeout) → -n (non-blocking) mit Retry-Loop
LEASE_ACQUIRED=false
for i in $(seq 1 900); do
if flock -n "$LEASE_LOCK" -c true 2>/dev/null; then
LEASE_ACQUIRED=true
break
fi
sleep 1
done
if [ "$LEASE_ACQUIRED" != "true" ]; then
log "WARNUNG: Lease-Lock nach 15 Minuten nicht erhalten; fahre ohne Lock fort"
fi
register_lease
else
register_lease
fi