fix(search): skip deletion of missing temporary indexes
ci / db / db (push) Successful in 52s
ci / api / api (push) Successful in 42s

This commit is contained in:
mrleo1nid committed 2026-10-28 23:56:46 +03:00
1 parent 66d3897f66
commit f59d1e8d03
3 files changed
+67 -1

No files matched your search

+16
View File
@@ -114,6 +114,22 @@ func (m *Meili) call(ctx context.Context, method, path string, body any) error {
return m.wait(ctx, t)
}
// deleteIndexIfExists не создаёт заведомо провальную задачу удаления, если индекса нет.
func (m *Meili) deleteIndexIfExists(ctx context.Context, uid string) error {
path := "/indexes/" + uid
if err := m.do(ctx, http.MethodGet, path, nil, nil); err != nil {
if errors.Is(err, ErrMeiliNotFound) {
return nil
}
return err
}
// Индекс мог исчезнуть между проверкой и выполнением асинхронной задачи.
if err := m.call(ctx, http.MethodDelete, path, nil); err != nil && !errors.Is(err, ErrMeiliNotFound) {
return err
}
return nil
}
// Healthy — Meilisearch отвечает.
func (m *Meili) Healthy(ctx context.Context) error {
return m.do(ctx, http.MethodGet, "/health", nil, nil)