revCacheLoaderForDocumentCV used either during cache miss (from revCacheLoaderForCv), or used directly when getting current active CV from cache nolint:staticcheck
(ctx context.Context, backingStore RevisionCacheBackingStore, doc *Document, cv Version, loadBackup bool)
| 472 | // revCacheLoaderForDocumentCV used either during cache miss (from revCacheLoaderForCv), or used directly when getting current active CV from cache |
| 473 | // nolint:staticcheck |
| 474 | func revCacheLoaderForDocumentCV(ctx context.Context, backingStore RevisionCacheBackingStore, doc *Document, cv Version, loadBackup bool) (bodyBytes []byte, history Revisions, channels base.Set, removed bool, attachments AttachmentsMeta, deleted bool, expiry *time.Time, revid string, hlv *HybridLogicalVector, err error) { |
| 475 | if bodyBytes, attachments, channels, deleted, err = backingStore.getCurrentVersion(ctx, doc, cv, loadBackup); err != nil { |
| 476 | return nil, nil, nil, false, nil, false, nil, "", nil, err |
| 477 | } |
| 478 | |
| 479 | // if we have request current version on the doc we can add revision ID too. If not we cannot know what the |
| 480 | // corresponding revID is to pair with the request CV |
| 481 | if doc.HLV.ExtractCurrentVersionFromHLV().Equal(cv) { |
| 482 | revid = doc.GetRevTreeID() |
| 483 | deleted = doc.Deleted |
| 484 | hlv = doc.HLV |
| 485 | } |
| 486 | |
| 487 | validatedHistory, getHistoryErr := doc.History.getHistory(revid) |
| 488 | if getHistoryErr != nil { |
| 489 | return bodyBytes, history, channels, removed, attachments, deleted, doc.Expiry, revid, hlv, err |
| 490 | } |
| 491 | history = encodeRevisions(ctx, doc.ID, validatedHistory) |
| 492 | |
| 493 | return bodyBytes, history, channels, removed, attachments, deleted, doc.Expiry, revid, hlv, err |
| 494 | } |
| 495 | |
| 496 | func (c *DatabaseCollection) getCurrentVersion(ctx context.Context, doc *Document, cv Version, loadBackup bool) (bodyBytes []byte, attachments AttachmentsMeta, channels base.Set, deleted bool, err error) { |
| 497 | if err = doc.HasCurrentVersion(ctx, cv); err != nil { |
no test coverage detected