refs #1701. Updated Sync with ogLive. Parse new data
parent
1f4a88df0f
commit
5be87008c4
|
@ -7,7 +7,7 @@ namespace App\Controller\OgBoot;
|
|||
use App\Controller\OgBoot\PxeBootFile\PostAction;
|
||||
use App\Service\Trace\CreateService;
|
||||
use App\Service\Utils\ExtractOgLiveFilenameDateService;
|
||||
use App\Service\Utils\SymflipyOgLiveFilenameService;
|
||||
use App\Service\Utils\SimplifyOgLiveFilenameService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
|
@ -34,7 +34,7 @@ abstract class AbstractOgBootController extends AbstractController
|
|||
protected readonly EntityManagerInterface $entityManager,
|
||||
protected readonly HttpClientInterface $httpClient,
|
||||
protected readonly CreateService $createService,
|
||||
protected readonly SymflipyOgLiveFilenameService $symflipyOgLiveFilenameService,
|
||||
protected readonly SimplifyOgLiveFilenameService $simplifyOgLiveFilenameService,
|
||||
protected readonly ExtractOgLiveFilenameDateService $extractOgLiveFilenameDateService,
|
||||
)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ class GetIsosAction extends AbstractOgBootController
|
|||
}
|
||||
|
||||
$isos = array_map(function ($iso) {
|
||||
$filename = $this->symflipyOgLiveFilenameService->__invoke($iso['filename']);
|
||||
$filename = $this->simplifyOgLiveFilenameService->__invoke($iso['filename']);
|
||||
|
||||
return [
|
||||
'id' => $iso['id'],
|
||||
|
|
|
@ -49,7 +49,7 @@ class InstallAction extends AbstractOgBootController
|
|||
|
||||
$this->createService->__invoke(null, CommandTypes::INSTALL_OGLIVE, TraceStatus::IN_PROGRESS, 'InstallOgLive_'.$data->getUuid(), $inputData);
|
||||
|
||||
$data->setName($this->symflipyOgLiveFilenameService->__invoke($data->getFilename()));
|
||||
$data->setName($this->simplifyOgLiveFilenameService->__invoke($data->getFilename()));
|
||||
$data->setDate(new \DateTime());
|
||||
$data->setStatus(OgLiveStatus::PENDING);
|
||||
$this->entityManager->persist($data);
|
||||
|
|
|
@ -76,7 +76,7 @@ class SyncAction extends AbstractOgBootController
|
|||
*/
|
||||
private function extracted(OgLive $ogLiveEntity, mixed $ogLive): void
|
||||
{
|
||||
$ogLiveEntity->setName($this->symflipyOgLiveFilenameService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory'])));
|
||||
$ogLiveEntity->setName($this->simplifyOgLiveFilenameService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory'])));
|
||||
$ogLiveEntity->setDate(new \DateTime($this->extractOgLiveFilenameDateService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory']))));
|
||||
$ogLiveEntity->setInstalled(true);
|
||||
$ogLiveEntity->setArchitecture($ogLive['architecture']);
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Entity\Trace;
|
|||
use App\Model\OgLiveStatus;
|
||||
use App\Model\TraceStatus;
|
||||
use App\Service\Utils\ExtractOgLiveFilenameDateService;
|
||||
use App\Service\Utils\SimplifyOgLiveFilenameService;
|
||||
use App\Service\Utils\SymflipyOgLiveFilenameService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -34,7 +35,7 @@ class InstallOgLiveResponseAction extends AbstractController
|
|||
public function __construct(
|
||||
protected readonly EntityManagerInterface $entityManager,
|
||||
protected readonly LoggerInterface $logger,
|
||||
protected readonly SymflipyOgLiveFilenameService $symflipyOgLiveFilenameService,
|
||||
protected readonly SimplifyOgLiveFilenameService $simplifyOgLiveFilenameService,
|
||||
protected readonly ExtractOgLiveFilenameDateService $extractOgLiveFilenameDateService,
|
||||
)
|
||||
{
|
||||
|
@ -93,7 +94,7 @@ class InstallOgLiveResponseAction extends AbstractController
|
|||
private function updateOgLive (OgLive $ogLive, mixed $details, string $status): void
|
||||
{
|
||||
if ( is_array($details) && $status === self::OG_LIVE_INSTALL_SUCCESS) {
|
||||
$ogLive->setName($this->symflipyOgLiveFilenameService->__invoke($details['directory']));
|
||||
$ogLive->setName($this->simplifyOgLiveFilenameService->__invoke($details['directory']));
|
||||
$ogLive->setDate(new \DateTime($this->extractOgLiveFilenameDateService->__invoke($details['directory'])));
|
||||
$ogLive->setFilename(str_replace(self::OG_BOOT_DIRECTORY, '', $details['directory']));
|
||||
$ogLive->setInstalled(true);
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service\Utils;
|
||||
|
||||
class SymflipyOgLiveFilenameService
|
||||
{
|
||||
public function __invoke(string $filename): string
|
||||
{
|
||||
if (preg_match('/^(.+)-r\d+\.[a-f0-9]+_(\d{8})(?:\.iso)?$/', $filename, $matches)) {
|
||||
return "{$matches[1]}-{$matches[2]}";
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue