|
|
@ -114,20 +114,21 @@ class Cache
|
|
|
|
|
|
|
|
|
|
|
|
$this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
|
|
|
|
$this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tempFileName = $this->root . $file . uniqid('.', true) . '.tmp';
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return file_put_contents($this->root . $file.'.tmp', $contents) !== false && rename($this->root . $file . '.tmp', $this->root . $file);
|
|
|
|
return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
|
|
|
|
} catch (\ErrorException $e) {
|
|
|
|
} catch (\ErrorException $e) {
|
|
|
|
$this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
|
|
|
|
$this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
|
|
|
|
if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
|
|
|
|
if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
|
|
|
|
// Remove partial file.
|
|
|
|
// Remove partial file.
|
|
|
|
unlink($this->root . $file);
|
|
|
|
unlink($tempFileName);
|
|
|
|
|
|
|
|
|
|
|
|
$message = sprintf(
|
|
|
|
$message = sprintf(
|
|
|
|
'<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
|
|
|
|
'<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
|
|
|
|
$this->root . $file,
|
|
|
|
$tempFileName,
|
|
|
|
$m[1],
|
|
|
|
$m[1],
|
|
|
|
$m[2],
|
|
|
|
$m[2],
|
|
|
|
@disk_free_space($this->root . dirname($file))
|
|
|
|
@disk_free_space(dirname($tempFileName))
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$this->io->writeError($message);
|
|
|
|
$this->io->writeError($message);
|
|
|
|