From c5676b094f67d9f612f1e5bc8c651e353311fd24 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 3 Mar 2025 09:15:39 +0100 Subject: [PATCH] Use /config/TemporaryFiles --- .../etc/cont-init.d/02-restorestreamdata.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 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 7a3a67bfd..fbdfe1a89 100755 --- a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh +++ b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh @@ -2,22 +2,23 @@ # shellcheck shell=bash set -e -if [ -d /data/StreamData ]; then +if [ -d /config/TemporaryFiles ]; then - # Check if there are .wav files in /data/StreamData - if find /data/StreamData -type f -name "*.wav" | grep -q .; then + # Check if there are .wav files in /config/TemporaryFiles + if find /config/TemporaryFiles -type f -name "*.wav" | grep -q .; then bashio::log.warning "Container was stopped while files were still being analyzed." - echo "... restoring .wav files from /data/StreamData to $HOME/BirdSongs/StreamData." + echo "... restoring .wav files from /config/TemporaryFiles to $HOME/BirdSongs/StreamData." # Create the destination directory if it does not exist mkdir -p "$HOME"/BirdSongs/StreamData # Count the number of .wav files to be moved - file_count=$(find /data/StreamData -type f -name "*.wav" | wc -l) + file_count=$(find /config/TemporaryFiles -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/ + mv -v /config/TemporaryFiles/*.wav "$HOME"/BirdSongs/StreamData/ + rm -r /config/TemporaryFiles # Update permissions only if files were moved successfully if [ "$file_count" -gt 0 ]; then @@ -30,7 +31,7 @@ if [ -d /data/StreamData ]; then fi # Clean up the source folder if it is empty - if [ -z "$(ls -A /data/StreamData)" ]; then - rm -r /data/StreamData + if [ -z "$(ls -A /config/TemporaryFiles)" ]; then + rm -r /config/TemporaryFiles fi fi