MCPcopy
hub / github.com/perkeep/perkeep / deleteDocAndImages

Method deleteDocAndImages

app/scanningcabinet/datastore.go:854–868  ·  view source on GitHub ↗

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

(ctx context.Context, docRef blob.Ref)

Source from the content-addressed store, hash-verified

852// deleteDocAndImages deletes the given document struct and marks all of its
853// associated mediaObjects as not being part of a document
854func (h *handler) deleteDocAndImages(ctx context.Context, docRef blob.Ref) error {
855 doc, err := h.fetchDocument(docRef)
856 if err != nil {
857 return fmt.Errorf("document %v not found: %v", docRef, err)
858 }
859 if err := h.deleteNode(ctx, docRef); err != nil {
860 return fmt.Errorf("could not delete document %v: %v", docRef, err)
861 }
862 for _, page := range doc.pages {
863 if err := h.deleteNode(ctx, page); err != nil {
864 return fmt.Errorf("could not delete scan %v: %v", page, err)
865 }
866 }
867 return nil
868}

Callers 1

handleChangedocMethod · 0.95

Calls 2

fetchDocumentMethod · 0.95
deleteNodeMethod · 0.95

Tested by

no test coverage detected