Retry json file writing 3 times before failing, fixes #2286
parent
3f8836ff10
commit
46e82cb38d
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue