refs #2212. Import image name fixed
testing/ogcore-api/pipeline/head This commit looks good Details

develop
Manuel Aranda Rosales 2025-07-15 09:42:47 +02:00
parent 65ae79d976
commit 2b939adc5b
2 changed files with 25 additions and 2 deletions

View File

@ -58,11 +58,11 @@ class ImportAction extends AbstractOgRepositoryController
}
$imageImageRepositoryEntity = new ImageImageRepository();
$imageImageRepositoryEntity->setName($imageEntity->getName().'_v'.$imageImageRepositoryEntity->getVersion() + 1);
$imageImageRepositoryEntity->setName($imageEntity->getName());
$imageImageRepositoryEntity->setStatus(ImageStatus::AUX_FILES_PENDING);
$imageImageRepositoryEntity->setImage($imageEntity);
$imageImageRepositoryEntity->setRepository($repository);
$imageImageRepositoryEntity->setVersion(1);
$imageImageRepositoryEntity->setVersion($this->extractVersionFromImageName($image));
$this->entityManager->persist($imageImageRepositoryEntity);
$this->entityManager->flush();
@ -90,4 +90,26 @@ class ImportAction extends AbstractOgRepositoryController
return new JsonResponse(data: [], status: Response::HTTP_OK);
}
private function extractVersionFromImageName(string $imageName): int
{
// Buscar patrones como "_v2", "_v3", etc.
if (preg_match('/_v(\d+)$/', $imageName, $matches)) {
return (int) $matches[1];
}
// Buscar patrones como "-v2", "-v3", etc.
if (preg_match('/-v(\d+)$/', $imageName, $matches)) {
return (int) $matches[1];
}
// Buscar patrones como "v2", "v3" al final del nombre
if (preg_match('/v(\d+)$/', $imageName, $matches)) {
return (int) $matches[1];
}
// Si no se encuentra ningún patrón de versión, devolver 1 por defecto
return 1;
}
}

View File

@ -96,6 +96,7 @@ class ResponseController extends AbstractOgRepositoryController
$newImageRepo->setImage($image);
$newImageRepo->setVersion($originImageImageRepository->getVersion());
$newImageRepo->setRepository($repository);
$newImageRepo->setPartitionInfo($originImageImageRepository->getPartitionInfo());
$newImageRepo->setStatus(ImageStatus::SUCCESS);
if ($trace->getInput()['imageImageRepositoryUuid'] ?? false) {