fix document delete last document

This commit is contained in:
team 1
2026-02-18 09:26:08 +01:00
parent 64b263c5fe
commit b1e1fe082e
3 changed files with 37 additions and 5 deletions

View File

@@ -425,6 +425,7 @@ class DocumentController extends AbstractController
EntityManagerInterface $em,
IngestJobService $jobService,
LockService $lockService,
DocumentService $documentService
): RedirectResponse
{
if (!$this->isCsrfTokenValid('delete_document_' . $id, $request->request->get('_token'))) {

View File

@@ -46,12 +46,35 @@ final class VectorIndexBuilder
{
$this->assertPreconditions();
// --------------------------------------------
// 🔵 FALL: NDJSON ist leer → kein Vector Index
// --------------------------------------------
if (filesize($this->indexNdjsonPath) === 0) {
// Alten Index entfernen
@unlink($this->vectorIndexPath);
@unlink($this->vectorMetaPath);
if ($logPath !== null) {
@file_put_contents(
$logPath,
"NDJSON empty → Vector index removed\n",
FILE_APPEND
);
}
return; // WICHTIG: kein Python, kein tmp, kein Fehler
}
// --------------------------------------------
// 🟢 FALL: NDJSON enthält Chunks
// --------------------------------------------
if (!is_file($this->indexMetaPath)) {
$this->initializeIndexMeta();
}
$indexMeta = $this->readIndexMeta();
$embeddingModel = $indexMeta['embedding_model'];
$tmpVectorIndexPath = $this->vectorIndexPath . '.tmp';

View File

@@ -80,8 +80,16 @@ with open(index_path, "r", encoding="utf-8") as f:
ids.append(chunk_id)
if not texts:
print("ERROR: No valid chunks found in index.ndjson")
sys.exit(21)
print("No chunks found. Removing vector index.")
if out_path.exists():
out_path.unlink()
meta_path = out_path.with_suffix(".meta.json")
if meta_path.exists():
meta_path.unlink()
sys.exit(0)
print(f"Loaded {len(texts)} chunks.")