feat: extract file text on every attach path and backfill on reindex
- inline and signed uploads queue the text job in their transaction - the admin form queues it in the save transaction - detach resyncs the material (its text row goes by cascade) - bm:materials-reindex backfills missing PDF texts before each sync
This commit is contained in:
@@ -134,6 +134,10 @@ func (h *Handlers) AttachMaterialInline(w http.ResponseWriter, r *http.Request)
|
||||
err := lagoon.Transaction(r.Context(), db, func(ctx context.Context, tx *gorm.DB) error {
|
||||
f, why, err := storeMaterialFile(ctx, tx, bucket, m, name, bytes.NewReader(data), lim)
|
||||
stored, refusal = f, why
|
||||
if err == nil && why == "" && f != nil {
|
||||
// The text job joins the transaction and syncs the material.
|
||||
h.MaterialIndex.QueueExtract(ctx, tx, m.ID)
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil || refusal != "" {
|
||||
@@ -302,6 +306,8 @@ func (h *Handlers) SignedMaterialUpload(w http.ResponseWriter, r *http.Request)
|
||||
refusal = singleFilePart
|
||||
return errUploadRefused
|
||||
}
|
||||
// The text job joins the transaction and syncs the material.
|
||||
h.MaterialIndex.QueueExtract(ctx, tx, m.ID)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user