Skip to content

Commit cf9debf

Browse files
authored
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
1 parent e1556aa commit cf9debf

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

pkg/model/loader.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ var knownModelsNameSuffixToSkip []string = []string{
193193
".pt",
194194
".onnx",
195195
".md",
196-
".MD",
197-
".DS_Store",
196+
".ds_store",
198197
".",
199198
".safetensors",
200199
".bin",
@@ -203,6 +202,7 @@ var knownModelsNameSuffixToSkip []string = []string{
203202
".ckpt",
204203
".zip",
205204
".tag",
205+
".bak",
206206
".partial",
207207
".tar.gz",
208208
}
@@ -225,12 +225,18 @@ FILE:
225225
}
226226
}
227227

228-
// Skip templates, YAML, .keep, .json, and .DS_Store files
228+
// Skip templates, YAML, .keep, .json, .DS_Store, and other non-model files.
229+
// Use case-insensitive matching so e.g. CACHEDIR.TAG is caught by ".tag".
230+
lowerName := strings.ToLower(file.Name())
229231
for _, skip := range knownModelsNameSuffixToSkip {
230-
if strings.HasSuffix(file.Name(), skip) {
232+
if strings.HasSuffix(lowerName, skip) {
231233
continue FILE
232234
}
233235
}
236+
// Skip backup files created by LocalAI or huggingface_hub (e.g. model.yaml.bak-pre-gpumem072).
237+
if strings.Contains(lowerName, ".bak") {
238+
continue FILE
239+
}
234240

235241
// Skip directories
236242
if file.IsDir() {

0 commit comments

Comments
 (0)