MCPcopy
hub / github.com/perkeep/perkeep / refreshDomainBlobs

Method refreshDomainBlobs

pkg/server/app/app.go:160–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

158var errRefreshSuppress = errors.New("refresh request suppressed")
159
160func (a *Handler) refreshDomainBlobs() error {
161 a.masterQueryMu.Lock()
162 defer a.masterQueryMu.Unlock()
163 if time.Now().Before(a.domainBlobsRefresh.Add(time.Minute)) {
164 // suppress refresh request to no more than once per minute
165 return errRefreshSuppress
166 }
167 if a.masterQuery == nil {
168 return errors.New("no master query")
169 }
170 sq := *(a.masterQuery)
171 sq.Describe = sq.Describe.Clone()
172 sr, err := a.sh.Query(context.TODO(), &sq)
173 if err != nil {
174 return fmt.Errorf("error running master query: %v", err)
175 }
176 a.domainBlobs = make(map[blob.Ref]bool, len(sr.Describe.Meta))
177 for _, v := range sr.Describe.Meta {
178 a.domainBlobs[v.BlobRef] = true
179 }
180 a.domainBlobsRefresh = time.Now()
181 return nil
182}
183
184// handleSearch runs the requested search query against the search handler, and
185// if the results are within the domain allowed by the master query, forwards them

Callers 2

handleMasterQueryMethod · 0.95
handleSearchMethod · 0.95

Calls 5

LockMethod · 0.80
UnlockMethod · 0.80
CloneMethod · 0.80
QueryMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected