mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-07 12:06:56 +03:00
refactor(install.sh): improve download retry logic
This commit is contained in:
14
install.sh
14
install.sh
@@ -47,23 +47,24 @@ main() {
|
|||||||
filename=$(basename "$url")
|
filename=$(basename "$url")
|
||||||
filepath="$DOWNLOAD_DIR/$filename"
|
filepath="$DOWNLOAD_DIR/$filename"
|
||||||
|
|
||||||
|
if [ -f "$filepath" ] && [ -s "$filepath" ]; then
|
||||||
|
echo "$filename has already been uploaded"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
attempt=0
|
attempt=0
|
||||||
while [ $attempt -lt $COUNT ]; do
|
while [ $attempt -lt $COUNT ]; do
|
||||||
if [ -f "$filepath" ] && [ -s "$filepath" ]; then
|
|
||||||
echo "$filename has already been uploaded"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Download $filename (count $((attempt+1)))..."
|
echo "Download $filename (count $((attempt+1)))..."
|
||||||
wget -q -O "$filepath" "$url"
|
wget -q -O "$filepath" "$url"
|
||||||
|
|
||||||
if [ -s "$filepath" ]; then
|
if [ -s "$filepath" ]; then
|
||||||
echo "$filename successfully downloaded"
|
echo "$filename successfully downloaded"
|
||||||
|
break
|
||||||
else
|
else
|
||||||
echo "Download error $filename. Retry..."
|
echo "Download error $filename. Retry..."
|
||||||
rm -f "$filepath"
|
rm -f "$filepath"
|
||||||
|
attempt=$((attempt+1))
|
||||||
fi
|
fi
|
||||||
attempt=$((attempt+1))
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -96,7 +97,6 @@ main() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
|
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
|
||||||
|
|
||||||
if [ "$IS_SHOULD_RESTART_NETWORK" ]; then
|
if [ "$IS_SHOULD_RESTART_NETWORK" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user