From 6f997a6e73d5a59d319c03aeebc559a6e26332ad Mon Sep 17 00:00:00 2001 From: Nikita Skryabin Date: Tue, 18 Feb 2025 09:58:26 +0300 Subject: [PATCH] refactor(install.sh): improve download retry logic --- install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 6c702b9..cb73e8e 100755 --- a/install.sh +++ b/install.sh @@ -47,23 +47,24 @@ main() { filename=$(basename "$url") filepath="$DOWNLOAD_DIR/$filename" + if [ -f "$filepath" ] && [ -s "$filepath" ]; then + echo "$filename has already been uploaded" + continue + fi + attempt=0 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)))..." wget -q -O "$filepath" "$url" if [ -s "$filepath" ]; then echo "$filename successfully downloaded" + break else echo "Download error $filename. Retry..." rm -f "$filepath" + attempt=$((attempt+1)) fi - attempt=$((attempt+1)) done done @@ -96,7 +97,6 @@ main() { done fi - find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \; if [ "$IS_SHOULD_RESTART_NETWORK" ]; then