fix: added required space arg to check-autobrr-space command
All checks were successful
ci / treefmt (push) Successful in 1m39s

This commit is contained in:
Ceferino Patino 2026-06-24 19:04:09 -05:00
commit 380f6473a9
Signed by: c4patino
SSH key fingerprint: SHA256:Wu+cU1t+7zVT9wzew/4meNmeulo66NzMqc22MdDBgXI

View file

@ -41,13 +41,26 @@ in {
checkAutobrrSpace = pkgs.writeShellScriptBin "check-autobrr-space" ''
set -euo pipefail
required_space=$((1024 * 1024 * 1024)) # 1 Tb
if [ "$#" -ne 2 ]; then
echo "Error: Missing argument" >&2
exit 1
fi
parse_space() {
local space="''${1^^}"
space="''${space%B}"
${pkgs.coreutils}/bin/numfmt --from=iec "$space"
}
required_space=$(parse_space "$1")
torrent_size="$2"
path="/mnt/nfs/servarr/torrents"
available_space=$(${pkgs.coreutils}/bin/df "$path" | \
${pkgs.gawk}/bin/awk 'END {print $4}')
available_space=$(${pkgs.coreutils}/bin/df --output=avail -B1 "$path" | \
${pkgs.gawk}/bin/awk 'END {print $1}')
remaining_space=$((available_space - torrent_size))
[ "$available_space" -gt "$required_space" ]
[ "$remaining_space" -gt "$required_space" ]
'';
in {
path = [checkAutobrrSpace];