MCPcopy
hub / github.com/perkeep/perkeep / createScan

Method createScan

app/scanningcabinet/datastore.go:301–323  ·  view source on GitHub ↗
(ctx context.Context, mo mediaObject)

Source from the content-addressed store, hash-verified

299}
300
301func (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.

Callers 1

handleUploadMethod · 0.95

Calls 3

newPermanodeMethod · 0.95
setAttributeMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected