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

Method setAttachments

db/attachment.go:266–282  ·  view source on GitHub ↗
(ctx context.Context, attachments updatedAttachments)

Source from the content-addressed store, hash-verified

264}
265
266func (db *DatabaseCollectionWithUser) setAttachments(ctx context.Context, attachments updatedAttachments) error {
267 for key, attachment := range attachments {
268 attachmentSize := int64(len(attachment.body))
269 if attachmentSize > int64(maxAttachmentSizeBytes) {
270 return ErrAttachmentTooLarge
271 }
272 _, err := db.dataStore.AddRaw(key, 0, attachment.body)
273 if err == nil {
274 base.InfofCtx(ctx, base.KeyCRUD, "\tAdded attachment %q", base.UD(key))
275 db.dbStats().CBLReplicationPush().AttachmentPushCount.Add(1)
276 db.dbStats().CBLReplicationPush().AttachmentPushBytes.Add(attachmentSize)
277 } else {
278 return err
279 }
280 }
281 return nil
282}
283
284type AttachmentCallback func(name string, digest string, knownData []byte, meta map[string]interface{}) ([]byte, error)
285

Callers 1

addAttachmentsMethod · 0.95

Calls 6

InfofCtxFunction · 0.92
UDFunction · 0.92
CBLReplicationPushMethod · 0.80
dbStatsMethod · 0.80
AddRawMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected