overleaf/services/web/bin/compress_batch_of_assets
Jakob Ackermann cc78541714 Merge pull request #5670 from overleaf/jpa-cdn-pre-compress
[web] cdn_upload: compress assets prior to uploading them to GCS

GitOrigin-RevId: a9b0970beb124d20bd2ffe21d30a674ffafd6258
2021-11-04 09:03:32 +00:00

16 lines
302 B
Bash
Executable file

#!/usr/bin/env bash
set -e
for file in "$@"; do
file_gzipped="compressed/$file"
gzip -9 --no-name --stdout "$file" > "$file_gzipped"
before=$(stat -c%s "$file")
after=$(stat -c%s "$file_gzipped")
if [[ "$after" -ge "$before" ]]; then
rm "$file_gzipped"
else
rm "$file"
fi
done