1
0
Fork 0

Retry json file writing 3 times before failing, fixes #2286

pull/2294/head
Jordi Boggiano 2013-09-26 12:23:57 +02:00
parent 3f8836ff10
commit 46e82cb38d
1 changed files with 15 additions and 1 deletions

View File

@ -117,7 +117,21 @@ class JsonFile
);
}
}
$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;
}
}
}
/**