From ce36c99daee0f3b441bb17f7a39f5e9284645a90 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Wed, 25 Jul 2018 14:57:07 +0200 Subject: [PATCH] download fix --- home.admin/50downloadHDD.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/home.admin/50downloadHDD.sh b/home.admin/50downloadHDD.sh index 4e06049..fc2310d 100755 --- a/home.admin/50downloadHDD.sh +++ b/home.admin/50downloadHDD.sh @@ -2,6 +2,8 @@ # name of torrentfile = name of directory in torrent torrent="raspiblitz-hdd-2018-07-16" +# size of a valid download (run on seed directory 'du -s ./[TORRENTDIRECTORY]') +torrentsize=462470200 echo "" echo "*** Checking HDD ***" @@ -21,10 +23,33 @@ if [ ${mountOK} -eq 1 ]; then echo "killall transmission-cli" > $tmpfile sudo transmission-cli ./assets/$torrent.torrent -D -w /mnt/hdd -f $tmpfile echo "" + echo "*** Checking Download ***" + echo "wait a moment" + sleep 5 + downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') + if [ ${#downloadsize} -eq 0 ]; then + downloadsize=0 + fi + # add some tolerance for checking + torrentsize="$(($torrentsize-1024000))" + echo "download size is(${downloadsize})" + if [ ${downloadsize} -lt ${torrentsize} ]; then + echo "FAIL - download is not ${torrentsize}" + sleep 3 + dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want to clean all download data before you continue?" 6 57 + response=$? + case $response in + 0) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; + esac + # + ./00mainMenu.sh + exit 1; + fi + echo "" + echo "*** Moving Files ***" echo "moving files ..." - mv /mnt/hdd/$torrent/* /mnt/hdd - rm -R /mnt/hdd/$torrent + sudo mv /mnt/hdd/$torrent /mnt/hdd/bitcoin echo "" # set SetupState