mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2026-02-04 02:25:30 +00:00
BUGFIX: keep fts5 tables syncronized
This commit is contained in:
@@ -253,6 +253,19 @@ func (p *ReiheEditPage) POSTDelete(engine *templating.Engine, app core.App) Hand
|
||||
})
|
||||
}
|
||||
|
||||
// Delete series and entries from FTS5 asynchronously
|
||||
go func(appInstance core.App, seriesID string, deletedEntries []*dbmodels.Entry) {
|
||||
if err := dbmodels.DeleteFTS5Series(appInstance, seriesID); err != nil {
|
||||
appInstance.Logger().Error("Failed to delete series from FTS5", "series_id", seriesID, "error", err)
|
||||
}
|
||||
|
||||
for _, entry := range deletedEntries {
|
||||
if err := dbmodels.DeleteFTS5Entry(appInstance, entry.Id); err != nil {
|
||||
appInstance.Logger().Error("Failed to delete FTS5 entry", "entry_id", entry.Id, "error", err)
|
||||
}
|
||||
}
|
||||
}(app, series.Id, preferredEntries)
|
||||
|
||||
return e.JSON(http.StatusOK, map[string]any{
|
||||
"success": true,
|
||||
"redirect": "/reihen",
|
||||
@@ -405,6 +418,18 @@ func (p *ReiheEditPage) POST(engine *templating.Engine, app core.App) HandleFunc
|
||||
return p.renderError(engine, app, e, "Speichern fehlgeschlagen.")
|
||||
}
|
||||
|
||||
// Update FTS5 index for series and all related entries asynchronously
|
||||
go func(appInstance core.App, seriesID string) {
|
||||
freshSeries, err := dbmodels.Series_ID(appInstance, seriesID)
|
||||
if err != nil {
|
||||
appInstance.Logger().Error("Failed to load series for FTS5 update", "series_id", seriesID, "error", err)
|
||||
return
|
||||
}
|
||||
if err := dbmodels.UpdateFTS5SeriesAndRelatedEntries(appInstance, freshSeries); err != nil {
|
||||
appInstance.Logger().Error("Failed to update FTS5 index for series and related records", "series_id", seriesID, "error", err)
|
||||
}
|
||||
}(app, series.Id)
|
||||
|
||||
redirect := fmt.Sprintf("/reihe/%s/edit?saved_message=%s", id, url.QueryEscape("Änderungen gespeichert."))
|
||||
return e.Redirect(http.StatusSeeOther, redirect)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user