code: func (h *handler) updateScan(ctx context.Context, pn blob.Ref, new, old *mediaObject) error {
  	if old == nil {
  		mo, err := h.fetchScan(pn)
  		if err != nil {
  			return fmt.Errorf("scan %v not found: %v", pn, err)
  		}
  		old = &mo
  	}
  	if new.contentRef.Valid() && old.contentRef != new.contentRef {
  		if err := h.setAttribute(ctx, pn, "camliContent", new.contentRef.String()); err != nil {
  			return fmt.Errorf("could not set contentRef for scan %v: %v", pn, err)
  		}
  	}
  	if new.documentRef.Valid() && old.documentRef != new.documentRef {
  		if err := h.setAttribute(ctx, pn, "document", new.documentRef.String()); err != nil {
  			return fmt.Errorf("could not set documentRef for scan %v: %v", pn, err)
  		}
  	}
  	if !old.creation.Equal(new.creation) {
  		if new.creation.IsZero() {
  			if err := h.delAttribute(ctx, pn, nodeattr.DateCreated, ""); err != nil {
  				return fmt.Errorf("could not delete creation date for scan %v: %v", pn, err)
  			}
  		} else {
  			if err := h.setAttribute(ctx, pn, nodeattr.DateCreated, new.creation.UTC().Format(time.RFC3339)); err != nil {
  				return fmt.Errorf("could not set creation date for scan %v: %v", pn, err)
  			}
  		}
  	}
  	return nil
  }
docs: // old is an optimization, in case the caller already had fetched the old scan.
  // If nil, the current scan will be fetched for comparison with new.