fix document delete last document
This commit is contained in:
@@ -425,6 +425,7 @@ class DocumentController extends AbstractController
|
|||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
IngestJobService $jobService,
|
IngestJobService $jobService,
|
||||||
LockService $lockService,
|
LockService $lockService,
|
||||||
|
DocumentService $documentService
|
||||||
): RedirectResponse
|
): RedirectResponse
|
||||||
{
|
{
|
||||||
if (!$this->isCsrfTokenValid('delete_document_' . $id, $request->request->get('_token'))) {
|
if (!$this->isCsrfTokenValid('delete_document_' . $id, $request->request->get('_token'))) {
|
||||||
|
|||||||
@@ -46,12 +46,35 @@ final class VectorIndexBuilder
|
|||||||
{
|
{
|
||||||
$this->assertPreconditions();
|
$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)) {
|
if (!is_file($this->indexMetaPath)) {
|
||||||
$this->initializeIndexMeta();
|
$this->initializeIndexMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
$indexMeta = $this->readIndexMeta();
|
$indexMeta = $this->readIndexMeta();
|
||||||
|
|
||||||
$embeddingModel = $indexMeta['embedding_model'];
|
$embeddingModel = $indexMeta['embedding_model'];
|
||||||
|
|
||||||
$tmpVectorIndexPath = $this->vectorIndexPath . '.tmp';
|
$tmpVectorIndexPath = $this->vectorIndexPath . '.tmp';
|
||||||
|
|||||||
@@ -80,8 +80,16 @@ with open(index_path, "r", encoding="utf-8") as f:
|
|||||||
ids.append(chunk_id)
|
ids.append(chunk_id)
|
||||||
|
|
||||||
if not texts:
|
if not texts:
|
||||||
print("ERROR: No valid chunks found in index.ndjson")
|
print("No chunks found. Removing vector index.")
|
||||||
sys.exit(21)
|
|
||||||
|
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.")
|
print(f"Loaded {len(texts)} chunks.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user