From 2fde15678a056df0553783bd4df47bd095104362 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sat, 5 Oct 2024 10:20:33 +0200 Subject: [PATCH] Leaner code, rsync usage --- birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh | 8 +++++--- 1 file changed, 5 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 61fca2bc6..e515ae302 100755 --- a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh +++ b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh @@ -4,12 +4,15 @@ # Check if there are files in "$HOME"/BirdSongs/StreamData and move them to /data/StreamData if [ -d /data/StreamData ] && [ "$(ls -A /data/StreamData/)" ]; then - bashio::log.warning "Container was stopped while files were still being analysed, restoring them" + # Count the number of .wav files in /data/StreamData + wav_count=$(find /data/StreamData -type f -name "*.wav" | wc -l) + bashio::log.warning "Container was stopped while files were still being analyzed, restoring $wav_count .wav files" # Copy files - if [ "$(ls -A /data/StreamData)" ]; then + if [ "$wav_count" -gt 0 ]; then mv -v /data/StreamData/* "$HOME"/BirdSongs/StreamData/ fi + echo "... done" echo "" @@ -21,4 +24,3 @@ if [ -d /data/StreamData ] && [ "$(ls -A /data/StreamData/)" ]; then rm -r /data/StreamData fi -