MCPcopy
hub / github.com/perkeep/perkeep / breakAndDeleteDoc

Method breakAndDeleteDoc

app/scanningcabinet/datastore.go:836–850  ·  view source on GitHub ↗

breakAndDeleteDoc deletes the given document struct and marks all of its associated mediaObject as not being part of a document

(ctx context.Context, docRef blob.Ref)

Source from the content-addressed store, hash-verified

834// breakAndDeleteDoc deletes the given document struct and marks all of its
835// associated mediaObject as not being part of a document
836func (h *handler) breakAndDeleteDoc(ctx context.Context, docRef blob.Ref) error {
837 doc, err := h.fetchDocument(docRef)
838 if err != nil {
839 return fmt.Errorf("document %v not found: %v", docRef, err)
840 }
841 if err := h.deleteNode(ctx, docRef); err != nil {
842 return fmt.Errorf("could not delete document %v: %v", docRef, err)
843 }
844 for _, page := range doc.pages {
845 if err := h.delAttribute(ctx, page, "document", ""); err != nil {
846 return fmt.Errorf("could not unset document of scan %v: %v", page, err)
847 }
848 }
849 return nil
850}
851
852// deleteDocAndImages deletes the given document struct and marks all of its
853// associated mediaObjects as not being part of a document

Callers 1

handleChangedocMethod · 0.95

Calls 3

fetchDocumentMethod · 0.95
deleteNodeMethod · 0.95
delAttributeMethod · 0.95

Tested by

no test coverage detected