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

Method backupRevisionJSON

db/revision.go:298–316  ·  view source on GitHub ↗

Makes a backup of revision body for use by in-flight replications requesting an old revision (for clients not supporting replacementRevs)

(ctx context.Context, docId, oldRev string, oldBody []byte, channels base.Set, deleted bool)

Source from the content-addressed store, hash-verified

296
297// Makes a backup of revision body for use by in-flight replications requesting an old revision (for clients not supporting replacementRevs)
298func (db *DatabaseCollectionWithUser) backupRevisionJSON(ctx context.Context, docId, oldRev string, oldBody []byte, channels base.Set, deleted bool) {
299 if db.deltaSyncEnabled() && db.deltaSyncRevMaxAgeSeconds() > 0 {
300 // See postWriteUpdateHLV - we're writing a CV and RevTreeID backup there to support delta sync
301 return
302 }
303
304 if !db.storeLegacyRevTreeData() {
305 // Not storing legacy revtree data - nothing to do
306 return
307 }
308
309 // skip backup if this was a deletion
310 if len(oldBody) == 0 {
311 return
312 }
313
314 // store or refresh the old document revision by revtree ID for in-flight replications
315 _ = db.refreshOldRevisionJSON(ctx, docId, oldRev, oldBody, db.oldRevExpirySeconds(), channels, deleted)
316}
317
318// setOldRevisionJSONBody stores the raw JSON body of a revision that has been archived to a separate doc.
319func (db *DatabaseCollectionWithUser) setOldRevisionJSONBody(ctx context.Context, docid string, rev string, body []byte, expiry uint32) error {

Callers 1

backupAncestorRevsMethod · 0.95

Calls 5

deltaSyncEnabledMethod · 0.80
oldRevExpirySecondsMethod · 0.80

Tested by

no test coverage detected