Improve code

This commit is contained in:
Alexandre
2024-10-07 14:47:18 +02:00
committed by GitHub
parent 2ae39b5502
commit e47504cd75

View File

@@ -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