MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / migrateRevisionBodies

Method migrateRevisionBodies

db/document.go:909–927  ·  view source on GitHub ↗

Move any large revision bodies to external document storage

(ctx context.Context, dataStore base.DataStore)

Source from the content-addressed store, hash-verified

907
908// Move any large revision bodies to external document storage
909func (doc *Document) migrateRevisionBodies(ctx context.Context, dataStore base.DataStore) error {
910
911 for _, revID := range doc.History.GetLeaves() {
912 revInfo, err := doc.History.getInfo(revID)
913 if err != nil {
914 continue
915 }
916 if len(revInfo.Body) > MaximumInlineBodySize {
917 bodyKey := generateRevBodyKey(doc.ID, revID)
918 persistErr := doc.persistRevisionBody(dataStore, bodyKey, revInfo.Body)
919 if persistErr != nil {
920 base.WarnfCtx(ctx, "Unable to store revision body for doc %s, rev %s externally: %v", base.UD(doc.ID), revID, persistErr)
921 continue
922 }
923 revInfo.BodyKey = bodyKey
924 }
925 }
926 return nil
927}
928
929func generateRevBodyKey(docid, revid string) (revBodyKey string) {
930 return base.RevBodyPrefix + generateRevDigest(docid, revid)

Callers 1

migrateMetadataMethod · 0.80

Calls 6

persistRevisionBodyMethod · 0.95
WarnfCtxFunction · 0.92
UDFunction · 0.92
generateRevBodyKeyFunction · 0.85
GetLeavesMethod · 0.80
getInfoMethod · 0.80

Tested by

no test coverage detected