(ctx context.Context, attachments updatedAttachments)
| 264 | } |
| 265 | |
| 266 | func (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 | |
| 284 | type AttachmentCallback func(name string, digest string, knownData []byte, meta map[string]interface{}) ([]byte, error) |
| 285 |
no test coverage detected