From 7489280a7a1247f23543343aba4e95bf2f2e8fa6 Mon Sep 17 00:00:00 2001 From: Ayoub Zaki Date: Mon, 3 Feb 2025 12:06:52 +0100 Subject: [PATCH] bmap-writer-stream.sh: fix error handling --- bmap-writer-stream.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bmap-writer-stream.sh b/bmap-writer-stream.sh index 030a492..c8ffde6 100755 --- a/bmap-writer-stream.sh +++ b/bmap-writer-stream.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh export PATH=$PWD:$PATH @@ -20,12 +20,12 @@ fi BMAP_URL=$(echo "$IMAGE_URL" | sed 's/\.[^.]*$/.bmap/') BMAP_FILE=$(echo "$BMAP_URL" | sed 's/.*\///') - BMAP_FILE="${BMAP_FILE}_" + echo "Downloading $BMAP_URL to $BMAP_FILE" $WGET -q $BMAP_URL -O $BMAP_FILE -if [ $? -ne 0 ]; then - echo "Failed to download $BMAP_URL" +if [ $? -ne 0 ] || [ ! -f $BMAP_FILE ] || [ ! -s $BMAP_FILE ]; then + echo "Failed to download $BMAP_URL or file is empty" exit 1 fi echo "Streaming $IMAGE_URL to $DEVICE"