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)
| 852 | // deleteDocAndImages deletes the given document struct and marks all of its |
| 853 | // associated mediaObjects as not being part of a document |
| 854 | func (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 | } |
no test coverage detected