fix: use actual filename for face_gallery resource name, add dedup
This commit is contained in:
parent
8a9ec59134
commit
daa5da3b85
@ -43,8 +43,9 @@ func (s *Server) handleResourcesStatus(w http.ResponseWriter, r *http.Request) {
|
||||
fgPath := filepath.Join(s.agentCfg.ModelsDir, "face_gallery.db")
|
||||
if st, err := os.Stat(fgPath); err == nil {
|
||||
sha, _ := fileSHA256HTTP(fgPath)
|
||||
name := strings.TrimSuffix(filepath.Base(fgPath), filepath.Ext(fgPath))
|
||||
resources = append(resources, installedResource{
|
||||
Name: "face_gallery_v1",
|
||||
Name: name,
|
||||
ResourceType: "face_gallery",
|
||||
SHA256: sha,
|
||||
SizeBytes: st.Size(),
|
||||
@ -95,7 +96,18 @@ func (s *Server) handleResourcesStatus(w http.ResponseWriter, r *http.Request) {
|
||||
return resources[i].Name < resources[j].Name
|
||||
})
|
||||
|
||||
writeJSON(w, http.StatusOK, map[string]any{"resources": resources})
|
||||
// dedup by resource_type + name (face_gallery.db may appear both in modelsDir and resources/)
|
||||
seen := make(map[string]bool, len(resources))
|
||||
deduped := make([]installedResource, 0, len(resources))
|
||||
for _, r := range resources {
|
||||
key := r.ResourceType + "/" + r.Name
|
||||
if !seen[key] {
|
||||
seen[key] = true
|
||||
deduped = append(deduped, r)
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, map[string]any{"resources": deduped})
|
||||
}
|
||||
|
||||
// handleResourceUpload accepts a resource file upload.
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user