(ctx context.Context, doc *Document, cv Version, loadBackup bool)
| 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 { |
| 498 | if !loadBackup { |
| 499 | // do not attempt to fetch backup revision by CV unless specified |
| 500 | return nil, nil, nil, false, ErrMissing |
| 501 | } |
| 502 | bodyBytes, channels, deleted, err = c.getOldRevisionJSON(ctx, doc.ID, base.Crc32cHashString([]byte(cv.String()))) |
| 503 | if err != nil || bodyBytes == nil { |
| 504 | return nil, nil, nil, false, err |
| 505 | } |
| 506 | } else { |
| 507 | bodyBytes, err = doc.BodyBytes(ctx) |
| 508 | if err != nil { |
| 509 | base.WarnfCtx(ctx, "Marshal error when retrieving active current version body: %v", err) |
| 510 | return nil, nil, nil, false, err |
| 511 | } |
| 512 | channels = doc.SyncData.getCurrentChannels() |
| 513 | attachments = doc.Attachments() |
| 514 | } |
| 515 | |
| 516 | // handle backup revision inline attachments, or pre-2.5 meta |
| 517 | if inlineAtts, cleanBodyBytes, _, err := extractInlineAttachments(bodyBytes); err != nil { |
| 518 | return nil, nil, nil, false, err |
| 519 | } else if len(inlineAtts) > 0 { |
| 520 | // we found some inline attachments, so merge them with attachments, and update the bodies |
| 521 | attachments = mergeAttachments(inlineAtts, attachments) |
| 522 | bodyBytes = cleanBodyBytes |
| 523 | } |
| 524 | return bodyBytes, attachments, channels, deleted, err |
| 525 | } |
nothing calls this directly
no test coverage detected