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)
| 46 | |
| 47 | // setOldRevisionJSONPtr stores a pointer from the old revision's RevTreeID to the Current Version hash used to fetch the body. |
| 48 | func (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 | } |
no test coverage detected