Browse Source

uploadZipFromPath

frederic 3 years ago
parent
commit
fb7a7d1a61
1 changed files with 4 additions and 18 deletions
  1. 4
    18
      Entity/ZipFile.php

+ 4
- 18
Entity/ZipFile.php View File

@@ -334,27 +334,13 @@ class ZipFile extends AbstractEntity
334 334
      */
335 335
     public function uploadZipFromPath(string $zipPath, string $uploadPath)
336 336
     {
337
-        $response = array();
338
-        $response['existingFile'] = null;
339
-        $response['upload'] = false;
340
-
341 337
         if (file_exists($zipPath)) {
342 338
             // Récupération de la signature du zip
343
-            $hash = md5_file($zipPath);
344
-
345
-            // Test de l'existance de la signature
346
-            $repository = $this->entityManager->getRepository(ZipFile::class);
347
-            $oldZipFile = $repository->findOneBy(['zip_fileprint' => $hash]);
348
-            // si le fichier existe déjà, on renvoie son id
349
-            if (!empty($oldZipFile)) {
350
-                $response['existingFile'] = $oldZipFile;
351
-                return $response;
352
-            }
353
-
354 339
             //upload du fichier coté moteur
355 340
             $uploadDate = new \DateTime('NOW');
356 341
             $fileName = pathinfo($zipPath)['filename'];
357
-            $filePath = $uploadPath . $fileName;
342
+            $hash = md5_file($zipPath);
343
+            $filePath = $uploadPath . '/'.$hash;
358 344
             if (copy($zipPath, $filePath)) {
359 345
                 $this->importStatus = self::IMPORT_STATUS_PROCESSING;
360 346
             }
@@ -365,10 +351,10 @@ class ZipFile extends AbstractEntity
365 351
             $this->uploadDate = $uploadDate;
366 352
             $this->endUploadDate = $endUploadDate;
367 353
 
368
-            $response['upload'] = true;
354
+            return true;
369 355
         }
370 356
 
371
-        return $response;
357
+        return false;
372 358
     }
373 359
 
374 360
     /**

Loading…
Cancel
Save