From 4ed2ed49a85978b0ffcda9bbe50db948518b9e89 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Tue, 28 Jan 2025 00:26:51 +0800 Subject: [PATCH] perf(plugin-search): improve search cache (#451) --- plugins/plugin-search/src/node/prepareSearchIndex.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/plugin-search/src/node/prepareSearchIndex.ts b/plugins/plugin-search/src/node/prepareSearchIndex.ts index 94691768..d5965982 100644 --- a/plugins/plugin-search/src/node/prepareSearchIndex.ts +++ b/plugins/plugin-search/src/node/prepareSearchIndex.ts @@ -92,7 +92,8 @@ export async function onSearchIndexRemoved( const locale = page.pathLocale const index = getIndexByLocale(locale, searchOptions) const cache = getIndexCache(fileId) - index.removeAll(cache) + if (cache && cache.length) + index.removeAll(cache) await writeTemp(app) } }