fix: resolve stat command multi-line output breaking verify command
The stat command was producing multi-line output which broke the pipe-delimited return format of verify_model_download(). Fixed by: - Testing which stat format works (Linux vs macOS) before executing - Using proper format flags to get single-line date output - Defaulting to 'Unknown' instead of relying on fallback chain This fixes the issue where all models showed as 'NOT DOWNLOADED' even when present in the cache.
This commit is contained in:
@@ -638,18 +638,11 @@ verify_model_download() {
|
|||||||
local expected_size_gb="$2"
|
local expected_size_gb="$2"
|
||||||
local filename_filter="$3"
|
local filename_filter="$3"
|
||||||
|
|
||||||
# DEBUG: Show what we're checking
|
|
||||||
echo "DEBUG_BASH: Checking repo_id='$repo_id' filter='$filename_filter' CACHE_DIR='$CACHE_DIR'" >&2
|
|
||||||
|
|
||||||
# Find model files in cache
|
# Find model files in cache
|
||||||
# Capture both stdout (file paths) and stderr (error messages)
|
# Capture both stdout (file paths) and stderr (error messages)
|
||||||
local find_output
|
local find_output
|
||||||
find_output=$(find_model_files "$repo_id" "$filename_filter" 2>&1)
|
find_output=$(find_model_files "$repo_id" "$filename_filter" 2>&1)
|
||||||
|
|
||||||
# DEBUG: Show raw output
|
|
||||||
echo "DEBUG_BASH: find_output length=${#find_output}" >&2
|
|
||||||
echo "DEBUG_BASH: find_output first 200 chars: ${find_output:0:200}" >&2
|
|
||||||
|
|
||||||
# Separate file paths from error/debug messages
|
# Separate file paths from error/debug messages
|
||||||
local model_files
|
local model_files
|
||||||
model_files=$(echo "$find_output" | grep -v "^ERROR:" | grep -v "^WARN:" | grep -v "^DEBUG:")
|
model_files=$(echo "$find_output" | grep -v "^ERROR:" | grep -v "^WARN:" | grep -v "^DEBUG:")
|
||||||
@@ -680,13 +673,17 @@ verify_model_download() {
|
|||||||
cache_path=$(echo "$model_files" | head -n1 | xargs dirname)
|
cache_path=$(echo "$model_files" | head -n1 | xargs dirname)
|
||||||
|
|
||||||
# Get modification time of first file
|
# Get modification time of first file
|
||||||
local mod_time=""
|
local mod_time="Unknown"
|
||||||
if [[ -n "$model_files" ]]; then
|
if [[ -n "$model_files" ]]; then
|
||||||
local first_file
|
local first_file
|
||||||
first_file=$(echo "$model_files" | head -n1)
|
first_file=$(echo "$model_files" | head -n1)
|
||||||
if [[ -f "$first_file" ]]; then
|
if [[ -f "$first_file" ]]; then
|
||||||
mod_time=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S" "$first_file" 2>/dev/null || \
|
# Try Linux stat first (most common), then macOS stat
|
||||||
stat -c "%y" "$first_file" 2>/dev/null | cut -d'.' -f1 || echo "Unknown")
|
if stat -c "%y" "$first_file" >/dev/null 2>&1; then
|
||||||
|
mod_time=$(stat -c "%y" "$first_file" 2>/dev/null | cut -d'.' -f1)
|
||||||
|
elif stat -f "%Sm" "$first_file" >/dev/null 2>&1; then
|
||||||
|
mod_time=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S" "$first_file" 2>/dev/null)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user