From e47504cd75fa26840ce60ed475f450cfa183dd5a Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:47:18 +0200 Subject: [PATCH] Improve code --- .../rootfs/etc/cont-init.d/02-restorestreamdata.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh index a3227c7a3..8a32a8dc1 100755 --- a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh +++ b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh @@ -7,14 +7,17 @@ if [ -d /data/StreamData ]; then # Check if there are .wav files in /data/StreamData if find /data/StreamData -type f -name "*.wav" | grep -q .; then - bashio::log.fatal "Restoring .wav files from /data/StreamData to $HOME/BirdSongs/StreamData." + bashio::log.warning "Restoring .wav files from /data/StreamData to $HOME/BirdSongs/StreamData." + + # Count the number of .wav files to be moved + file_count=$(find /data/StreamData -type f -name "*.wav" | wc -l) + echo "... found $file_count .wav files to restore." # Move the .wav files using `mv` to avoid double log entries mv -v /data/StreamData/*.wav "$HOME"/BirdSongs/StreamData/ - bashio::log.fatal "... files restored successfully, allowing container to stop." else - bashio::log.info "No .wav files found to restore." + echo "... no .wav files found to restore." fi # Clean up the source folder if empty