1111use Symfony \Component \Filesystem \Filesystem ;
1212use Symfony \Component \Process \Exception \ProcessFailedException ;
1313use Symfony \Component \Process \Process ;
14- use League \Flysystem \FilesystemOperator ;
1514
1615class ValidationManager
1716{
@@ -41,11 +40,6 @@ class ValidationManager
4140 */
4241 private $ zipArchiveValidator ;
4342
44- /**
45- * @var FilesystemOperator
46- */
47- private $ dataStorage ;
48-
4943 /**
5044 * Current validation (in order to handle SIGTERM)
5145 * @var Validation
@@ -55,14 +49,12 @@ class ValidationManager
5549 public function __construct (
5650 EntityManagerInterface $ em ,
5751 ValidationsStorage $ storage ,
58- FilesystemOperator $ dataStorage ,
5952 ValidatorCLI $ validatorCli ,
6053 ZipArchiveValidator $ zipArchiveValidator ,
6154 LoggerInterface $ logger
6255 ) {
6356 $ this ->em = $ em ;
6457 $ this ->storage = $ storage ;
65- $ this ->dataStorage = $ dataStorage ;
6658 $ this ->validatorCli = $ validatorCli ;
6759 $ this ->zipArchiveValidator = $ zipArchiveValidator ;
6860 $ this ->logger = $ logger ;
@@ -94,15 +86,15 @@ public function archive(Validation $validation)
9486 'uid ' => $ validation ->getUid (),
9587 ]);
9688 $ uploadDirectory = $ this ->storage ->getUploadDirectory ($ validation );
97- if ($ this ->dataStorage ->directoryExists ($ uploadDirectory )) {
98- $ this ->dataStorage ->deleteDirectory ($ uploadDirectory );
89+ if ($ this ->storage -> getStorage () ->directoryExists ($ uploadDirectory )) {
90+ $ this ->storage -> getStorage () ->deleteDirectory ($ uploadDirectory );
9991 }
10092 $ this ->logger ->info ('Validation[{uid}] : remove output files ' , [
10193 'uid ' => $ validation ->getUid (),
10294 ]);
10395 $ outputDirectory = $ this ->storage ->getOutputDirectory ($ validation );
104- if ($ this ->dataStorage ->directoryExists ($ outputDirectory )) {
105- $ this ->dataStorage ->deleteDirectory ($ outputDirectory );
96+ if ($ this ->storage -> getStorage () ->directoryExists ($ outputDirectory )) {
97+ $ this ->storage -> getStorage () ->deleteDirectory ($ outputDirectory );
10698 }
10799 $ this ->logger ->info ('Validation[{uid}] : archive removing all files : completed ' , [
108100 'uid ' => $ validation ->getUid (),
@@ -248,7 +240,7 @@ private function getZip(Validation $validation)
248240
249241 file_put_contents (
250242 $ zipPath ,
251- $ this ->dataStorage ->read ($ uploadFile )
243+ $ this ->storage -> getStorage () ->read ($ uploadFile )
252244 );
253245 }
254246
@@ -343,15 +335,15 @@ private function saveToStorage(Validation $validation)
343335 $ validationDirectory = $ this ->storage ->getDirectory ($ validation );
344336 $ normDataPath = $ validationDirectory . '/validation/ ' . $ validation ->getDatasetName () . '.zip ' ;
345337 $ outputDirectory = $ this ->storage ->getOutputDirectory ($ validation );
346- if (! $ this ->dataStorage ->directoryExists ($ outputDirectory )){
347- $ this ->dataStorage ->createDirectory ($ outputDirectory );
338+ if (! $ this ->storage -> getStorage () ->directoryExists ($ outputDirectory )){
339+ $ this ->storage -> getStorage () ->createDirectory ($ outputDirectory );
348340 }
349341 $ outputPath = $ outputDirectory . $ validation ->getDatasetName () . '.zip ' ;
350- if ($ this ->dataStorage ->fileExists ($ outputPath )){
351- $ this ->dataStorage ->delete ($ outputPath );
342+ if ($ this ->storage -> getStorage () ->fileExists ($ outputPath )){
343+ $ this ->storage -> getStorage () ->delete ($ outputPath );
352344 }
353345 $ stream = fopen ($ normDataPath , 'r+ ' );
354- $ this ->dataStorage ->writeStream ($ outputPath , $ stream );
346+ $ this ->storage -> getStorage () ->writeStream ($ outputPath , $ stream );
355347 fclose ($ stream );
356348
357349 // Saves validator logs to storage
@@ -363,7 +355,7 @@ private function saveToStorage(Validation $validation)
363355 $ outputPath = $ outputDirectory . '/validator-debug.log ' ;
364356
365357 $ stream = fopen ($ logPath , 'r+ ' );
366- $ this ->dataStorage ->writeStream ($ outputPath , $ stream );
358+ $ this ->storage -> getStorage () ->writeStream ($ outputPath , $ stream );
367359 fclose ($ stream );
368360 }
369361
0 commit comments