fix(search): skip deletion of missing temporary indexes
This commit is contained in:
1 parent
66d3897f66
commit
f59d1e8d03
3 files changed
+67
-1
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user