From 44fc25068d277ee99cacd3124f30b577724d4ef3 Mon Sep 17 00:00:00 2001 From: "Mike Kostersitz (Oilcan Productions)" <77457397+oilcan-productions@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:18:23 -0700 Subject: [PATCH] Update deploy-ftp.sh Adding retry logic for creatin the tar ball to ensure what we upload is valid. --- build/deploy-ftp.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/build/deploy-ftp.sh b/build/deploy-ftp.sh index 82ed067a3..41f929398 100644 --- a/build/deploy-ftp.sh +++ b/build/deploy-ftp.sh @@ -19,7 +19,28 @@ echo "password $FTP_SECRET" >> "$NETRC" chmod 600 "$NETRC" upload_file(){ - (cd out; tar czf $EMULATOR.tgz $EMULATOR) + MAX_RETRIES=5 + RETRY_COUNT=0 + + while (( RETRY_COUNT < MAX_RETRIES )); do + (cd out; tar czf $EMULATOR.tgz $EMULATOR) + + # Verify the tarball + if tar tf $EMULATOR.tgz >/dev/null 2>&1; then + echo "Tarball is valid and can be expanded." + break + else + echo "Tarball is not valid or cannot be expanded. Retrying..." + RETRY_COUNT=$((RETRY_COUNT + 1)) + rm -f $EMULATOR.tgz + continue + fi + done + + if (( RETRY_COUNT == MAX_RETRIES )); then + echo "Failed to create a valid tarball after $MAX_RETRIES attempts." + return 1 + fi echo "Deploying as $USER at $HOST" @@ -33,6 +54,7 @@ bye EOF } + test_archive_integrity(){ echo "Testing download of $EMULATOR.tgz" mkdir -p "$TESTDIR"