From 577369a54fd73c18cdc132b2b4cf5a09e3d0f171 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 11 Jun 2024 02:10:36 +0200 Subject: [PATCH] feat: Check diskspace before download (#583) --- Dockerfile | 2 +- src/mido.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ff94b1f..4f671e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM scratch -COPY --from=qemux/qemu-docker:5.12 / / +COPY --from=qemux/qemu-docker:5.13 / / ARG VERSION_ARG="0.0" ARG DEBCONF_NOWARNINGS="yes" diff --git a/src/mido.sh b/src/mido.sh index 98d0505..897542d 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -418,6 +418,7 @@ getESD() { { wget "$winCatalog" -O "$dir/$wFile" -q --timeout=30; rc=$?; } || : msg="Failed to download $winCatalog" + (( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1 (( rc == 4 )) && error "$msg , network failure!" && return 1 (( rc == 8 )) && error "$msg , server issued an error response!" && return 1 (( rc != 0 )) && error "$msg , reason: $rc" && return 1 @@ -509,10 +510,16 @@ downloadFile() { local size="$4" local lang="$5" local desc="$6" - local rc total progress domain dots + local rc total progress domain dots space folder rm -f "$iso" + if [ -n "$size" ] && [[ "$size" != "0" ]]; then + folder=$(dirname -- "$iso") + space=$(df --output=avail -B 1 "$folder" | tail -n 1) + (( size > space )) && error "Not enough free space left to download file!" && return 1 + fi + # Check if running with interactive TTY or redirected to docker log if [ -t 1 ]; then progress="--progress=bar:noscroll" @@ -548,6 +555,7 @@ downloadFile() { fi msg="Failed to download $url" + (( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1 (( rc == 4 )) && error "$msg , network failure!" && return 1 (( rc == 8 )) && error "$msg , server issued an error response!" && return 1