From 94e2326158b2a512758b2c2a043eea88cee769eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Tue, 25 Nov 2025 15:21:27 +0100 Subject: [PATCH] fix: follow symlinks when calculating model disk usage HuggingFace models use symlinks pointing to blobs in the cache. The stat command was returning the size of the symlink itself (76 bytes) instead of the actual file it points to. Fixed by: - Adding -L flag to stat commands to follow symlinks - Testing which stat format works (Linux -c vs macOS -f) before executing - Using proper spacing and quotes in stat commands - Checking for both regular files and symlinks in the condition This fixes disk usage showing as 1 KB instead of the actual ~50+ GB for models like FLUX. --- artifact_huggingface_download.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/artifact_huggingface_download.sh b/artifact_huggingface_download.sh index 88907ba..3e92ad1 100755 --- a/artifact_huggingface_download.sh +++ b/artifact_huggingface_download.sh @@ -607,9 +607,17 @@ get_model_disk_usage() { local total_bytes=0 while IFS= read -r file_path; do - if [[ -f "$file_path" ]]; then + if [[ -f "$file_path" ]] || [[ -L "$file_path" ]]; then local file_size - file_size=$(stat -f%z "$file_path" 2>/dev/null || stat -c%s "$file_path" 2>/dev/null || echo "0") + # Use -L to follow symlinks (HuggingFace uses symlinks to blobs) + # Try Linux stat first, then macOS stat + if stat -L -c "%s" "$file_path" >/dev/null 2>&1; then + file_size=$(stat -L -c "%s" "$file_path" 2>/dev/null) + elif stat -L -f "%z" "$file_path" >/dev/null 2>&1; then + file_size=$(stat -L -f "%z" "$file_path" 2>/dev/null) + else + file_size=0 + fi total_bytes=$((total_bytes + file_size)) fi done <<< "$model_files"