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:
@@ -26,6 +26,11 @@ func (r *recordingIndex) RemoveAfterCommit(_ context.Context, tx *gorm.DB, id ui
|
||||
r.txs = append(r.txs, tx)
|
||||
}
|
||||
|
||||
func (r *recordingIndex) QueueExtract(_ context.Context, tx *gorm.DB, id uint) {
|
||||
r.calls = append(r.calls, "queue "+itoa(id))
|
||||
r.txs = append(r.txs, tx)
|
||||
}
|
||||
|
||||
func itoa(id uint) string { return strconv.FormatUint(uint64(id), 10) }
|
||||
|
||||
func TestMaterialsAdminHooks(t *testing.T) {
|
||||
@@ -53,7 +58,9 @@ func TestMaterialsAdminHooks(t *testing.T) {
|
||||
if err := c.FormAfterDelete(ctx, m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want := []string{"sync 7", "sync 7", "remove 7"}; !slices.Equal(rec.calls, want) {
|
||||
// Create and update queue the file text job (in the save transaction)
|
||||
// before the after-commit sync; delete queues nothing.
|
||||
if want := []string{"queue 7", "sync 7", "queue 7", "sync 7", "remove 7"}; !slices.Equal(rec.calls, want) {
|
||||
t.Errorf("calls = %v, want %v", rec.calls, want)
|
||||
}
|
||||
// Outside a cabana write there is no transaction: the index then runs
|
||||
|
||||
Reference in New Issue
Block a user