MCPcopy
hub / github.com/mudler/LocalAI / FindDuplicate

Method FindDuplicate

core/services/distributed/gallery.go:175–184  ·  view source on GitHub ↗

FindDuplicate checks if another instance is already downloading the same element. Only considers records updated within the last 30 minutes as active — older in-progress records are assumed to be stale (crashed instance).

(elementName string)

Source from the content-addressed store, hash-verified

173// Only considers records updated within the last 30 minutes as active — older
174// in-progress records are assumed to be stale (crashed instance).
175func (s *GalleryStore) FindDuplicate(elementName string) (*GalleryOperationRecord, error) {
176 var op GalleryOperationRecord
177 staleCutoff := time.Now().Add(-30 * time.Minute)
178 err := s.db.Where("gallery_element_name = ? AND status IN ? AND updated_at > ?", elementName,
179 activeStatuses, staleCutoff).First(&op).Error
180 if err != nil {
181 return nil, err
182 }
183 return &op, nil
184}
185
186// Cancel marks an operation as cancelled.
187func (s *GalleryStore) Cancel(id string) error {

Callers 4

backendHandlerMethod · 0.80
modelHandlerMethod · 0.80
phase4_test.goFile · 0.80

Calls 1

AddMethod · 0.80

Tested by

no test coverage detected