summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Graham <joseph@fibreglass.tunachunks>2014-06-15 16:15:01 +0100
committerJoseph Graham <joseph@fibreglass.tunachunks>2014-06-15 16:15:01 +0100
commit8048e6e1fbc881cbfb157fa7ed13007c2a6dd845 (patch)
tree41461530d4e42d9ffe3ff0cf284fe12f6beb5a57
parentabbbe43fbd694f19df83600d7de300eae9f2587a (diff)
Grr, 0% stuff, man.
-rw-r--r--pacman2pacman-get54
1 files changed, 49 insertions, 5 deletions
diff --git a/pacman2pacman-get b/pacman2pacman-get
index 5e982c1..e821e1b 100644
--- a/pacman2pacman-get
+++ b/pacman2pacman-get
@@ -141,18 +141,65 @@ then
# Display a progress bar until it's finished and then hardlink it to
# the right place.
- progress='0%'
+ progress='0.0%'
echo -n "Pacman2pacman p2p download: ${pname}: ${progress}"
+ count=0
+
+ declare -a last_webseed_check=(0 'working')
+
+ webseed_check_after='100'
+
until [[ "${progress}" == '100%' ]]
do
progress=$(transmission-remote -t "${id}" -i | grep 'Percent Done:')
progress="${progress##* }" # Remove stuff we don't want
+ # If we're still at 0.0% after ${webseed_check_after} attempts
+ # then we check if the webseed is actually valid.
+ if (( count >= webseed_check_after )) && [[ "${progress}" == '0.0%' ]]
+ then
+ # Find out if we already checked recently.
+ if (( (last_webseed_check[0] + (webseed_check_after / 2)) > count ))
+ then
+ if [[ last_webseed_check[1] == 'broken' ]]
+ then
+ # Just set the message without checking.
+ progress='0.0% Warning: Webseed dead...'
+ else
+ # We don't need to do anything
+ true
+ fi
+ else
+ if ! $(curl -IL "${url}" | grep '200 OK' &>/dev/null)
+ then
+ # The webseed seems to be invalid so we print an error
+ # message and exit.
+
+ progress='0.0% Warning: Webseed dead...' # This most
+ # likely means
+ # the user
+ # needs to run
+ # pacman -Sy,
+ # or that their
+ # internet is
+ # down.
+ last_webseed_check[0]="${count}"
+ last_webseed_check[1]="broken"
+ else
+ # The webseed is valid so we just record that we checked
+ last_webseed_check[0]="${count}"
+ last_webseed_check[1]="working"
+ fi
+ fi
+ fi
+
printf "\rPacman2pacman p2p download: %s: %s " "${pname}" "${progress}"
sleep 0.7
+
+ (( count ++ ))
done
echo
@@ -181,7 +228,7 @@ else
mod_time=$(stat -c %Y "/srv/pacman2pacman/dbcache/${filename##*/}" 2>/dev/null)
- progress='0%'
+ progress='0.0%'
echo -n "Pacman2pacman http download: ${pname}: ${progress}"
@@ -214,9 +261,6 @@ else
# start of the download. This should fix it.
[[ "${progress}" == '100.0%' ]] && continue
- # For consistency.
- [[ "${progress}" == '0.0%' ]] && progress='0%'
-
printf "\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
done