model: fix case-insensitive suffix matching and skip .bak files in ListFilesInModelPath (#10306)

model: skip .bak files and fix case-insensitive suffix matching in ListFilesInModelPath
This commit is contained in:
pos-ei-don
2026-06-13 17:46:46 +02:00
committed by GitHub
parent e1556aa1dc
commit cf9debf4eb

View File

@@ -193,8 +193,7 @@ var knownModelsNameSuffixToSkip []string = []string{
".pt",
".onnx",
".md",
".MD",
".DS_Store",
".ds_store",
".",
".safetensors",
".bin",
@@ -203,6 +202,7 @@ var knownModelsNameSuffixToSkip []string = []string{
".ckpt",
".zip",
".tag",
".bak",
".partial",
".tar.gz",
}
@@ -225,12 +225,18 @@ FILE:
}
}
// Skip templates, YAML, .keep, .json, and .DS_Store files
// Skip templates, YAML, .keep, .json, .DS_Store, and other non-model files.
// Use case-insensitive matching so e.g. CACHEDIR.TAG is caught by ".tag".
lowerName := strings.ToLower(file.Name())
for _, skip := range knownModelsNameSuffixToSkip {
if strings.HasSuffix(file.Name(), skip) {
if strings.HasSuffix(lowerName, skip) {
continue FILE
}
}
// Skip backup files created by LocalAI or huggingface_hub (e.g. model.yaml.bak-pre-gpumem072).
if strings.Contains(lowerName, ".bak") {
continue FILE
}
// Skip directories
if file.IsDir() {