diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 84d7e13..1ce4b30 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -90,13 +90,30 @@ if [ "$DRY_RUN" -eq 1 ]; then fi # ------------------------------------------------------------- 3. transfer +# rsync, not tar: most of a build is unchanged source maps, and over the link to +# Accra re-sending 16 MB every time is wasteful. --delete keeps the staging +# directory honest — without it a staging area quietly accumulates every asset +# ever built, which is exactly how stale chunks kept coming back. A trailing +# slash on the source copies the contents, dotfiles included, so .htaccess comes +# along; `dist/*` would skip it. say "Transferring to $SSH_HOST:~/$STAGING" -COPYFILE_DISABLE=1 tar -C "$DIST" -cf - . 2>/dev/null \ - | ssh -o BatchMode=yes "$SSH_HOST" " - rm -rf ~/$STAGING && mkdir -p ~/$STAGING && - tar -C ~/$STAGING -xf - 2>/dev/null - find ~/$STAGING -name '._*' -delete - " || die "the transfer failed" +if command -v rsync >/dev/null 2>&1; then + rsync -a --delete --no-perms --no-owner --no-group --info=stats2 \ + -e "ssh -o BatchMode=yes" \ + "$DIST"/ "$SSH_HOST:~/$STAGING/" 2>/dev/null \ + | grep -E "Number of .*(transferred|deleted)|Total transferred" \ + | sed 's/^/ /' || die "rsync failed" +else + item "rsync not found locally — falling back to tar" + COPYFILE_DISABLE=1 tar -C "$DIST" -cf - . 2>/dev/null \ + | ssh -o BatchMode=yes "$SSH_HOST" " + rm -rf ~/$STAGING && mkdir -p ~/$STAGING && + tar -C ~/$STAGING -xf - 2>/dev/null + " || die "the transfer failed" +fi +# macOS tar writes AppleDouble companions when extended attributes are present; +# .htaccess arrived as ._.htaccess once. rsync does not, but sweep either way. +ssh -o BatchMode=yes "$SSH_HOST" "find ~/$STAGING -name '._*' -delete" || true REMOTE_FILES=$(ssh -o BatchMode=yes "$SSH_HOST" "find ~/$STAGING -type f | wc -l" | tr -d ' ') item "staged $REMOTE_FILES files"