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

Method setOldRevisionJSONPtr

db/revision_old.go:48–59  ·  view source on GitHub ↗

setOldRevisionJSONPtr stores a pointer from the old revision's RevTreeID to the Current Version hash used to fetch the body.

(ctx context.Context, doc *Document, expiry uint32)

Source from the content-addressed store, hash-verified

46
47// setOldRevisionJSONPtr stores a pointer from the old revision's RevTreeID to the Current Version hash used to fetch the body.
48func (db *DatabaseCollectionWithUser) setOldRevisionJSONPtr(ctx context.Context, doc *Document, expiry uint32) error {
49 ptrKey := oldRevisionKey(doc.ID, doc.GetRevTreeID())
50 revHash := base.Crc32cHashString([]byte(doc.HLV.GetCurrentVersionString()))
51 ptrBytes := withNonJSONPrefix(nonJSONPrefixKindRevPtr, []byte(revHash))
52 err := db.dataStore.SetRaw(ptrKey, expiry, nil, ptrBytes)
53 if err == nil {
54 base.DebugfCtx(ctx, base.KeyCRUD, "Backed up revision body legacy RevTree ID pointer %q -> %q/%q (%d bytes, ttl:%d)", doc.GetRevTreeID(), base.UD(doc.ID), revHash, len(ptrBytes), db.deltaSyncRevMaxAgeSeconds())
55 } else {
56 base.WarnfCtx(ctx, "Failed to write legacy rev pointer for %q rev %q: %v", base.UD(doc.ID), doc.GetRevTreeID(), err)
57 }
58 return err
59}

Callers 1

postWriteUpdateHLVMethod · 0.95

Calls 10

Crc32cHashStringFunction · 0.92
DebugfCtxFunction · 0.92
UDFunction · 0.92
WarnfCtxFunction · 0.92
oldRevisionKeyFunction · 0.85
withNonJSONPrefixFunction · 0.85
GetRevTreeIDMethod · 0.45
SetRawMethod · 0.45

Tested by

no test coverage detected