fix document delete last document
This commit is contained in:
@@ -234,7 +234,7 @@ class DocumentController extends AbstractController
|
||||
): RedirectResponse
|
||||
{
|
||||
|
||||
if (!$this->isCsrfTokenValid('activate_version_'.$versionId, $request->request->get('_token'))) {
|
||||
if (!$this->isCsrfTokenValid('activate_version_' . $versionId, $request->request->get('_token'))) {
|
||||
throw $this->createAccessDeniedException();
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ class DocumentController extends AbstractController
|
||||
): ?RedirectResponse
|
||||
{
|
||||
$dryRun = false;
|
||||
if (!$this->isCsrfTokenValid('ingest_version_'.$versionId, $request->request->get('_token'))) {
|
||||
if (!$this->isCsrfTokenValid('ingest_version_' . $versionId, $request->request->get('_token'))) {
|
||||
throw $this->createAccessDeniedException();
|
||||
}
|
||||
|
||||
@@ -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'))) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user