mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-10-17 05:14:19 +02:00
fix(kb): purge qdrant points when a zim is deleted (#1170)
delete() removed the file, the kiwix library entry, and the InstalledResource row, but never touched Qdrant or KbIngestState. A deleted ZIM kept surfacing as a search citation indefinitely. The sync sweep added in the previous commit would eventually catch these too, but no reason to wait for the next sync when we already know exactly what needs cleaning up right here.
This commit is contained in:
parent
18986e0527
commit
8eb172e684
|
|
@ -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 file
|
||||
const kiwixLibraryService = new KiwixLibraryService()
|
||||
await kiwixLibraryService.removeBook(fileName).catch((err) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user