1
0
Fork 0

Merge pull request #3207 from cs278/handle-low-diskspace

Handle low diskspace errors
pull/3365/head
Jordi Boggiano 2014-10-17 17:12:31 +01:00
commit be53c5dd2c
2 changed files with 26 additions and 1 deletions

View File

@ -83,7 +83,28 @@ class Cache
$this->io->write('Writing '.$this->root . $file.' into cache'); $this->io->write('Writing '.$this->root . $file.' into cache');
} }
try {
return file_put_contents($this->root . $file, $contents); return file_put_contents($this->root . $file, $contents);
} catch(\ErrorException $e) {
if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
// Remove partial file.
unlink($this->root . $file);
$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>',
$this->root . $file,
$m[1],
$m[2],
@disk_free_space($this->root . dirname($file))
);
$this->io->write($message);
return false;
}
throw $e;
}
} }
return false; return false;

View File

@ -221,6 +221,10 @@ class RemoteFilesystem
// work around issue with gzuncompress & co that do not work with all gzip checksums // work around issue with gzuncompress & co that do not work with all gzip checksums
$result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result)); $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
} }
if (!$result) {
throw new TransportException('Failed to decode zlib stream');
}
} }
} }