(ctx context.Context, mo mediaObject)
| 299 | } |
| 300 | |
| 301 | func (h *handler) createScan(ctx context.Context, mo mediaObject) (blob.Ref, error) { |
| 302 | pn, err := h.newPermanode() |
| 303 | if err != nil { |
| 304 | return pn, fmt.Errorf("could not create scan: %v", err) |
| 305 | } |
| 306 | |
| 307 | // make it a scan |
| 308 | if err := h.setAttribute(ctx, pn, nodeattr.Type, scanNodeType); err != nil { |
| 309 | return pn, fmt.Errorf("could not set %v as a scan: %v", pn, err) |
| 310 | } |
| 311 | |
| 312 | // give it content |
| 313 | if err := h.setAttribute(ctx, pn, nodeattr.CamliContent, mo.contentRef.String()); err != nil { |
| 314 | return pn, fmt.Errorf("could not set content for scan %v: %v", pn, err) |
| 315 | } |
| 316 | |
| 317 | // set creationTime |
| 318 | if err := h.setAttribute(ctx, pn, nodeattr.DateCreated, mo.creation.UTC().Format(time.RFC3339)); err != nil { |
| 319 | return pn, fmt.Errorf("could not set creationTime for scan %v: %v", pn, err) |
| 320 | } |
| 321 | |
| 322 | return pn, nil |
| 323 | } |
| 324 | |
| 325 | // old is an optimization, in case the caller already had fetched the old scan. |
| 326 | // If nil, the current scan will be fetched for comparison with new. |
no test coverage detected