Skip to content

Commit

Permalink
Update deploy-ftp.sh
Browse files Browse the repository at this point in the history
Adding retry logic for creatin the tar ball to ensure what we upload is valid.
  • Loading branch information
oilcan-productions authored Aug 23, 2024
1 parent bafb0c1 commit 44fc250
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion build/deploy-ftp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -33,6 +54,7 @@ bye
EOF
}


test_archive_integrity(){
echo "Testing download of $EMULATOR.tgz"
mkdir -p "$TESTDIR"
Expand Down

0 comments on commit 44fc250

Please sign in to comment.