diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index f7e1a2126..155f17e6e 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -117,7 +117,21 @@ class JsonFile ); } } - file_put_contents($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : '')); + + $retries = 3; + while ($retries--) { + try { + file_put_contents($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : '')); + break; + } catch (\Exception $e) { + if ($retries) { + usleep(500000); + continue; + } + + throw $e; + } + } } /**