Skip to content

Commit

Permalink
fix: clean normedZip from worker
Browse files Browse the repository at this point in the history
  • Loading branch information
DD-Arras committed Dec 2, 2024
1 parent 2ae9efc commit 28476eb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/Controller/Api/HealthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class HealthController extends AbstractController
/**
* Checks for Database connection
*
* @Route("/db", name="heatlh_db")
* @Route("/db", name="health_db")
*/
public function headthDB(EntityManager $entityManager)
public function healthDB(EntityManager $entityManager)
{
try{
$entityManager->getConnection()->connect();
Expand All @@ -36,9 +36,9 @@ public function headthDB(EntityManager $entityManager)
/**
* Checks for S3 connection
*
* @Route("/s3", name="heatlh_s3")
* @Route("/s3", name="health_s3")
*/
public function heatlhS3(FilesystemOperator $dataStorage)
public function healthS3(FilesystemOperator $dataStorage)
{
try {
$files = $dataStorage->listContents('.', TRUE);
Expand Down
54 changes: 32 additions & 22 deletions src/Validation/ValidationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ private function doProcess(Validation $validation)
$this->zipNormData($validation);

/*
* cleanup input data
* Save validation data to storage
*/
$this->cleanUp($validation);
$this->saveToStorage($validation);

/*
* Save validation data to storage
* cleanup data
*/
$this->saveToStorage($validation);
$this->cleanUp($validation);

$validation->setStatus(Validation::STATUS_FINISHED);
$this->logger->info("Validation[{uid}]: validation carried out successfully", ['uid' => $validation->getUid()]);
Expand Down Expand Up @@ -309,6 +309,26 @@ private function zipNormData(Validation $validation)
}
}

/**
* Saves normalized zip to storage
*/
private function saveToStorage(Validation $validation)
{
$this->logger->info('Validation[{uid}] : saving...', [
'uid' => $validation->getUid(),
'datasetName' => $validation->getDatasetName(),
]);
$validationDirectory = $this->storage->getDirectory($validation);
$normDataPath = $validationDirectory . '/validation/' . $validation->getDatasetName() . '.zip';

if ($this->dataStorage->fileExists($normDataPath)){
$this->dataStorage->delete($normDataPath);
}
$stream = fopen($normDataPath, 'r+');
$this->dataStorage->writeStream($normDataPath, $stream);
fclose($stream);
}

/**
* Cleans up temporary files
*
Expand Down Expand Up @@ -351,26 +371,16 @@ private function cleanUp(Validation $validation)
]);
$fs->remove($tempDatabase);
}
}

/**
* Saves normalized zip to storage
*/
private function saveToStorage(Validation $validation)
{
$this->logger->info('Validation[{uid}] : saving...', [
'uid' => $validation->getUid(),
'datasetName' => $validation->getDatasetName(),
]);
$validationDirectory = $this->storage->getDirectory($validation);
$normDataPath = $validationDirectory . '/validation/' . $validation->getDatasetName() . '.zip';

if ($this->dataStorage->fileExists($normDataPath)){
$this->dataStorage->delete($normDataPath);
// clean validation temporary zip
$tempZip = $validationDirectory . '/validation/' . $validation->getDatasetName() . '.zip';
if ($fs->exists($tempZip)) {
$this->logger->debug('Validation[{uid}] : rm -f {uid}/validation/' . $validation->getDatasetName() . '.zip...', [
'uid' => $validation->getUid(),
'datasetName' => $validation->getDatasetName(),
]);
$fs->remove($tempZip);
}
$stream = fopen($normDataPath, 'r+');
$this->dataStorage->writeStream($normDataPath, $stream);
fclose($stream);
}

/**
Expand Down

0 comments on commit 28476eb

Please sign in to comment.