MCPcopy Index your code
hub / github.com/perkeep/perkeep / setResultContinue

Method setResultContinue

pkg/search/query.go:1357–1380  ·  view source on GitHub ↗

setResultContinue sets res.Continue if q is suitable for having a continue token. The corpus is locked for reads.

(corpus *index.Corpus, res *SearchResult)

Source from the content-addressed store, hash-verified

1355// setResultContinue sets res.Continue if q is suitable for having a continue token.
1356// The corpus is locked for reads.
1357func (q *SearchQuery) setResultContinue(corpus *index.Corpus, res *SearchResult) {
1358 if !q.Constraint.onlyMatchesPermanode() {
1359 return
1360 }
1361 var pnTimeFunc func(blob.Ref) (t time.Time, ok bool)
1362 switch q.Sort {
1363 case LastModifiedDesc:
1364 pnTimeFunc = corpus.PermanodeModtime
1365 case CreatedDesc:
1366 pnTimeFunc = corpus.PermanodeAnyTime
1367 default:
1368 return
1369 }
1370
1371 if q.Limit <= 0 || len(res.Blobs) != q.Limit {
1372 return
1373 }
1374 lastpn := res.Blobs[len(res.Blobs)-1].Blob
1375 t, ok := pnTimeFunc(lastpn)
1376 if !ok {
1377 return
1378 }
1379 res.Continue = fmt.Sprintf("pn:%d:%v", t.UnixNano(), lastpn)
1380}
1381
1382type matchFn func(context.Context, *search, blob.Ref, camtypes.BlobMeta) (bool, error)
1383

Callers 1

QueryMethod · 0.80

Calls 1

onlyMatchesPermanodeMethod · 0.80

Tested by

no test coverage detected