This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

services.flix: pause sabnzbd below 100 GiB free, not just throttle

The previous guard only throttled sabnzbd below 100 GiB and paused at a
15 GiB floor, which still let the disk fill close to full. Use sabnzbd's
native download_free/complete_free (continuous pause + auto-resume) set
to 100 GiB so it pauses the moment free space drops below that, and have
the guard keep those configured. Transmission has no equivalent low-disk
guard, so the guard still throttles its downloads to a trickle below the
threshold while leaving seeding alone.

Assisted-by: Claude Code (claude-opus-4-8)

+22 -20
+22 -20
2configs/services/flix/default.nix
··· 140 140 ''; 141 141 }; 142 142 143 - # throttle downloads when /var/download runs low, so a full disk can no 144 - # longer hard-wedge sabnzbd with an unrecoverable "Disk full! Forcing Pause". 145 - # below THRESH GiB free: cap sabnzbd + transmission to a trickle. 146 - # below FLOOR GiB free: pause sabnzbd entirely (auto-resumes when space frees). 143 + # pause downloads when /var/download runs low, so a full disk can no longer 144 + # hard-wedge sabnzbd with an unrecoverable "Disk full! Forcing Pause". 145 + # sabnzbd pauses itself once free disk drops below download_free/complete_free 146 + # (auto-resuming above); this guard keeps those set to THRESH GiB and, since 147 + # transmission has no equivalent, throttles its downloads below the threshold. 147 148 systemd.services.download-space-guard = { 148 149 wantedBy = [ "multi-user.target" ]; 149 150 after = [ "sabnzbd.service" ]; ··· 159 160 set -efu 160 161 DIR=/var/download 161 162 THRESH=100 162 - FLOOR=15 163 163 164 164 avail=$(df -Pk "$DIR" | awk 'NR==2 {print int($4 / 1024 / 1024)}') 165 165 166 - key=$(grep -E '^api_key' /var/lib/sabnzbd/sabnzbd.ini | head -1 | cut -d= -f2 | tr -d ' ') 166 + INI=/var/lib/sabnzbd/sabnzbd.ini 167 + key=$(grep -E '^api_key' "$INI" | head -1 | cut -d= -f2 | tr -d ' ') 167 168 sab() { 168 - curl -fsS --max-time 15 "http://127.0.0.1:8080/api?output=json&apikey=$key&$1" >/dev/null 169 + curl -fsS --max-time 15 "http://127.0.0.1:8080/api?output=json&apikey=$key&$1" >/dev/null || : 169 170 } 171 + 172 + # sabnzbd pauses continuously once free disk drops below these (and 173 + # auto-resumes above). Keep them at THRESH GiB; re-assert only if changed. 174 + for k in download_free complete_free; do 175 + grep -qxF "$k = ''${THRESH}G" "$INI" \ 176 + || sab "mode=set_config&section=misc&keyword=$k&value=''${THRESH}G" 177 + done 178 + 179 + # transmission has no built-in low-disk guard: throttle its downloads to a 180 + # trickle below the threshold (seeding keeps running), lift it above. 170 181 tr_remote() { 171 182 transmission-remote 128.0.0.1:9091 "$@" >/dev/null || : 172 183 } 173 - 174 - if [ "$avail" -lt "$FLOOR" ]; then 175 - echo "free ''${avail}G < ''${FLOOR}G floor: pausing sabnzbd, throttling transmission to 500 KB/s" 176 - sab "mode=pause" 177 - tr_remote -d 500 178 - elif [ "$avail" -lt "$THRESH" ]; then 179 - echo "free ''${avail}G < ''${THRESH}G: throttling sabnzbd to 5 MB/s, transmission to 2 MB/s" 180 - sab "mode=resume" 181 - sab "mode=config&name=speedlimit&value=5M" 182 - tr_remote -d 2000 184 + if [ "$avail" -lt "$THRESH" ]; then 185 + echo "free ''${avail}G < ''${THRESH}G: sabnzbd paused by download_free, throttling transmission" 186 + tr_remote -d 1 183 187 else 184 - echo "free ''${avail}G >= ''${THRESH}G: removing download speed limits" 185 - sab "mode=resume" 186 - sab "mode=config&name=speedlimit&value=0" 188 + echo "free ''${avail}G >= ''${THRESH}G: downloads unrestricted" 187 189 tr_remote -D 188 190 fi 189 191 '';