Selaa lähdekoodia

Fail hard only after 3 failed attempts

Jordi Boggiano 12 vuotta sitten
vanhempi
commit
2c4c5dd764
1 muutettua tiedostoa jossa 13 lisäystä ja 12 poistoa
  1. 13 12
      src/Composer/Repository/ComposerRepository.php

+ 13 - 12
src/Composer/Repository/ComposerRepository.php

@@ -483,26 +483,27 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
 
                 break;
             } catch (\Exception $e) {
+                if ($retries) {
+                    usleep(100);
+                    continue;
+                }
+
                 if ($e instanceof RepositorySecurityException) {
                     throw $e;
                 }
 
-                if (!$retries) {
-                    if ($contents = $this->cache->read($cacheKey)) {
-                        if (!$this->degradedMode) {
-                            $this->io->write('<warning>'.$e->getMessage().'</warning>');
-                            $this->io->write('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
-                        }
-                        $this->degradedMode = true;
-                        $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
-
-                        break;
+                if ($contents = $this->cache->read($cacheKey)) {
+                    if (!$this->degradedMode) {
+                        $this->io->write('<warning>'.$e->getMessage().'</warning>');
+                        $this->io->write('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
                     }
+                    $this->degradedMode = true;
+                    $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
 
-                    throw $e;
+                    break;
                 }
 
-                usleep(100);
+                throw $e;
             }
         }