refactor: remove automatic diffusers→checkpoints dual-linking
Removed automatic checkpoint linking logic that was incorrectly duplicating diffusers models to checkpoints directory. Models should only be linked to their explicitly configured directory type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -537,50 +537,6 @@ link_model() {
|
||||
done <<< "$model_files"
|
||||
fi
|
||||
|
||||
# Also link checkpoint files to checkpoints/ directory if they exist
|
||||
# This handles models like SDXL that have both diffusers and checkpoint formats
|
||||
local checkpoint_dir="${COMFYUI_DIR}/checkpoints"
|
||||
if [[ "$model_type" == "diffusers" ]]; then
|
||||
# Clean existing checkpoint symlinks for this repo
|
||||
find "$checkpoint_dir" -type l -lname "*${repo_id/\//-}*" -delete 2>/dev/null || true
|
||||
|
||||
# Look for checkpoint .safetensors files in the snapshot root (not in subdirectories)
|
||||
# These are the consolidated model files like sd_xl_base_1.0.safetensors
|
||||
local checkpoint_files
|
||||
checkpoint_files=$(echo "$model_files" | grep -E 'snapshots/[^/]+/[^/]+\.safetensors$' | grep -vE '/(vae|text_encoder|transformer|unet|tokenizer)/' || true)
|
||||
|
||||
if [[ -n "$checkpoint_files" ]]; then
|
||||
mkdir -p "$checkpoint_dir"
|
||||
while IFS= read -r ckpt_file; do
|
||||
if [[ -f "$ckpt_file" ]] && [[ -n "$ckpt_file" ]]; then
|
||||
local ckpt_name=$(basename "$ckpt_file")
|
||||
|
||||
# Skip if it's clearly a component file (has parent directory in name)
|
||||
if [[ "$ckpt_file" =~ /(vae|text_encoder|transformer|unet|tokenizer)/ ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Only link if the file is large enough to be a checkpoint (> 500MB)
|
||||
# Use -L to follow symlinks (HuggingFace cache uses symlinks to blobs)
|
||||
local file_size=$(stat -L -c%s "$ckpt_file" 2>/dev/null || echo "0")
|
||||
if [[ $file_size -gt 524288000 ]]; then
|
||||
local ckpt_link="${checkpoint_dir}/${ckpt_name}"
|
||||
|
||||
# Remove existing symlink if it exists
|
||||
if [[ -L "$ckpt_link" ]]; then
|
||||
rm -f "$ckpt_link"
|
||||
fi
|
||||
|
||||
# Create symlink to checkpoints directory
|
||||
ln -s "$ckpt_file" "$ckpt_link"
|
||||
print_detail "${LINK} Also linked to checkpoints: ${DIM}${ckpt_name}${RESET}"
|
||||
linked_count=$((linked_count+1))
|
||||
fi
|
||||
fi
|
||||
done <<< "$checkpoint_files"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $linked_count -gt 0 ]]; then
|
||||
print_success "Linked ${linked_count} file(s) for ${BOLD_WHITE}${repo_id}${RESET}"
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user