From 3eb815b323e3c2d78a26e81e5710477af91719b6 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 6 Oct 2024 20:55:44 +0200 Subject: [PATCH] Leaner code --- birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh b/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh index 215b7f9fd..c92765c6d 100755 --- a/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh +++ b/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh @@ -8,10 +8,12 @@ if [ -d "$HOME"/BirdSongs/StreamData ]; then systemctl stop birdnet_analysis & systemctl stop birdnet_recording - # Check if there are files in StreamData and move them to /data/StreamData + # Ensure the target directory exists mkdir -p /data/StreamData + + # Use rsync to move files to /data/StreamData if [ "$(ls -A "$HOME"/BirdSongs/StreamData)" ]; then - mv -v "$HOME"/BirdSongs/StreamData/* /data/StreamData/ + rsync -av --remove-source-files "$HOME"/BirdSongs/StreamData/ /data/StreamData/ fi bashio::log.fatal "... files safe, allowing container to stop"