Merge pull request #22912 from owncloud/stable9-diskfreespace-filesworkaround

[stable9] Fix call to disk_free_space when a file is provided
This commit is contained in:
Thomas Müller 2016-03-10 15:31:38 +01:00
commit 730620cfb2
1 changed files with 9 additions and 1 deletions

View File

@ -252,7 +252,15 @@ class Local extends \OC\Files\Storage\Common {
}
public function free_space($path) {
$space = @disk_free_space($this->getSourcePath($path));
$sourcePath = $this->getSourcePath($path);
// using !is_dir because $sourcePath might be a part file or
// non-existing file, so we'd still want to use the parent dir
// in such cases
if (!is_dir($sourcePath)) {
// disk_free_space doesn't work on files
$sourcePath = dirname($sourcePath);
}
$space = @disk_free_space($sourcePath);
if ($space === false || is_null($space)) {
return \OCP\Files\FileInfo::SPACE_UNKNOWN;
}