mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-16 19:10:32 +02:00
Use /config/TemporaryFiles
This commit is contained in:
@@ -2,22 +2,23 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -d /data/StreamData ]; then
|
if [ -d /config/TemporaryFiles ]; then
|
||||||
|
|
||||||
# Check if there are .wav files in /data/StreamData
|
# Check if there are .wav files in /config/TemporaryFiles
|
||||||
if find /data/StreamData -type f -name "*.wav" | grep -q .; then
|
if find /config/TemporaryFiles -type f -name "*.wav" | grep -q .; then
|
||||||
bashio::log.warning "Container was stopped while files were still being analyzed."
|
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
|
# Create the destination directory if it does not exist
|
||||||
mkdir -p "$HOME"/BirdSongs/StreamData
|
mkdir -p "$HOME"/BirdSongs/StreamData
|
||||||
|
|
||||||
# Count the number of .wav files to be moved
|
# 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."
|
echo "... found $file_count .wav files to restore."
|
||||||
|
|
||||||
# Move the .wav files using `mv` to avoid double log entries
|
# 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
|
# Update permissions only if files were moved successfully
|
||||||
if [ "$file_count" -gt 0 ]; then
|
if [ "$file_count" -gt 0 ]; then
|
||||||
@@ -30,7 +31,7 @@ if [ -d /data/StreamData ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up the source folder if it is empty
|
# Clean up the source folder if it is empty
|
||||||
if [ -z "$(ls -A /data/StreamData)" ]; then
|
if [ -z "$(ls -A /config/TemporaryFiles)" ]; then
|
||||||
rm -r /data/StreamData
|
rm -r /config/TemporaryFiles
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user