harden document versions
This commit is contained in:
@@ -115,7 +115,9 @@ final class IngestOrchestrator
|
||||
return;
|
||||
}
|
||||
|
||||
if ($job->getType() !== IngestJob::TYPE_DOCUMENT) {
|
||||
$isActivateJob = $job->getType() === IngestJob::TYPE_DOCUMENT_VERSION_ACTIVATE;
|
||||
|
||||
if (!$isActivateJob && $job->getType() !== IngestJob::TYPE_DOCUMENT) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Unsupported ingest job type "%s".',
|
||||
$job->getType()
|
||||
@@ -139,21 +141,27 @@ final class IngestOrchestrator
|
||||
|
||||
$status = $version->getIngestStatus();
|
||||
|
||||
// Nur blockieren wenn wirklich schon indexed
|
||||
if ($status === DocumentVersion::INGEST_INDEXED) {
|
||||
throw new \RuntimeException('DocumentVersion already indexed.');
|
||||
// Bei Aktivierungs-Jobs IMMER re-ingestieren (auch wenn die Version früher schon indexed war).
|
||||
// Hintergrund: nach Aktivierung soll der Index deterministisch die aktive Version widerspiegeln.
|
||||
if (!$isActivateJob) {
|
||||
// Nur blockieren wenn wirklich schon indexed
|
||||
if ($status === DocumentVersion::INGEST_INDEXED) {
|
||||
throw new \RuntimeException('DocumentVersion already indexed.');
|
||||
}
|
||||
}
|
||||
|
||||
// RUNNING darf hier erlaubt sein (async!)
|
||||
if (!in_array($status, [
|
||||
DocumentVersion::INGEST_PENDING,
|
||||
DocumentVersion::INGEST_FAILED,
|
||||
DocumentVersion::INGEST_RUNNING,
|
||||
], true)) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Ingest not allowed for status "%s".',
|
||||
$status
|
||||
));
|
||||
if (!$isActivateJob) {
|
||||
if (!in_array($status, [
|
||||
DocumentVersion::INGEST_PENDING,
|
||||
DocumentVersion::INGEST_FAILED,
|
||||
DocumentVersion::INGEST_RUNNING,
|
||||
], true)) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Ingest not allowed for status "%s".',
|
||||
$status
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$version->setIngestStatus(DocumentVersion::INGEST_RUNNING);
|
||||
|
||||
Reference in New Issue
Block a user