Correctly return an empty string for empty files

This commit is contained in:
Joas Schilling 2016-04-08 14:50:42 +02:00
parent 6eefea1bb6
commit 178ad23d80
No known key found for this signature in database
GPG Key ID: 70A0B324C41C0946
1 changed files with 9 additions and 3 deletions

View File

@ -177,9 +177,15 @@ class Local extends \OC\Files\Storage\Common {
public function file_get_contents($path) { public function file_get_contents($path) {
// file_get_contents() has a memory leak: https://bugs.php.net/bug.php?id=61961 // file_get_contents() has a memory leak: https://bugs.php.net/bug.php?id=61961
$filename = $this->getSourcePath($path); $fileName = $this->getSourcePath($path);
$handle = fopen($filename,'rb');
$content = fread($handle, filesize($filename)); $fileSize = filesize($fileName);
if ($fileSize === 0) {
return '';
}
$handle = fopen($fileName,'rb');
$content = fread($handle, $fileSize);
fclose($handle); fclose($handle);
return $content; return $content;
} }