From dd83acc575e177707ca7166e80d66552dc53496e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 24 Jun 2025 22:29:13 +0200 Subject: [PATCH] use tar to speed up hash calculation by 10x --- mac/scripts/calculate-web-hash.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/mac/scripts/calculate-web-hash.sh b/mac/scripts/calculate-web-hash.sh index 13e452d5..328e907a 100755 --- a/mac/scripts/calculate-web-hash.sh +++ b/mac/scripts/calculate-web-hash.sh @@ -19,15 +19,11 @@ if [ ! -d "${WEB_DIR}" ]; then exit 1 fi -# Calculate hash of all relevant SOURCE files in web directory -# Include: src/, scripts/, config files (but NOT package-lock.json) -# Exclude: node_modules, dist, public (all are build outputs) echo "Calculating web content hash..." cd "${WEB_DIR}" -# Find all relevant files and calculate their size, modification time, and content hash -# This approach is more reliable than just content hash as it catches permission changes -# Exclude: node_modules, dist, public (all build outputs), package-lock.json, and build directories +# Use tar to create a single stream of all files for fast hashing +# This avoids spawning processes for each file CONTENT_HASH=$(find . \ -type f \ \( -name "*.ts" -o -name "*.js" -o -name "*.json" -o -name "*.css" -o -name "*.html" \ @@ -42,10 +38,9 @@ CONTENT_HASH=$(find . \ -not -path "./.node-builds/*" \ -not -path "./build/*" \ -not -path "./native/*" \ - -not -name "package-lock.json" \ - -exec stat -f "%m %z %p" {} \; \ - -exec shasum -a 256 {} \; | \ + -not -name "package-lock.json" | \ sort | \ + tar -cf - -T - 2>/dev/null | \ shasum -a 256 | \ cut -d' ' -f1)