Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.
TypeScript
fix(kb): purge qdrant points when a zim is deleted (#1170)
John Cortright8eb172e68483
diff --git a/admin/app/services/zim_service.ts b/admin/app/services/zim_service.tsindex 4cec723f..e7ac6c00 100644--- a/admin/app/services/zim_service.ts+++ b/admin/app/services/zim_service.ts@@ -34,6 +34,8 @@ import { SERVICE_NAMES } from '../../constants/service_names.js'import { CollectionManifestService } from './collection_manifest_service.js'import { KiwixCatalogService } from './kiwix_catalog_service.js'import { KiwixLibraryService } from './kiwix_library_service.js'+import { RagService } from './rag_service.js'+import { OllamaService } from './ollama_service.js'import type { CategoryWithStatus } from '../../types/collections.js'import CustomLibrarySource from '#models/custom_library_source'import { assertNotPrivateUrl } from '#validators/common'@@ -745,6 +747,18 @@ export class ZimService {await deleteFileIfExists(fullPath)+ // Purge this file's Qdrant points and KbIngestState row directly so a+ // deleted ZIM stops surfacing as a stale search citation immediately,+ // rather than waiting for the next scanAndSyncStorage reverse sweep to+ // catch it (#1170). Never touched Qdrant here before — the file's points+ // and state row would otherwise linger indefinitely.+ try {+ const ragService = new RagService(this.dockerService, new OllamaService())+ await ragService.purgeIndexedSource(fullPath)+ } catch (err) {+ logger.error(`[ZimService] Failed to purge knowledge-base entries for ${fullPath}:`, err)+ }+// Remove from kiwix library XML so --monitorLibrary stops serving the deleted fileconst kiwixLibraryService = new KiwixLibraryService()await kiwixLibraryService.removeBook(fileName).catch((err) => {