summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-03-07 10:58:24 +0100
committerVincent Petry <pvince81@owncloud.com>2016-03-07 11:01:24 +0100
commit89881ed5118f282bd3a93fe2dd092a296f17d2dc (patch)
tree666441039990d0d9f6c62d5dd2bbad1fd3ade752 /lib
parentc07b731689de6fe754e108688ccf71342aad95ef (diff)
downloadnextcloud-server-89881ed5118f282bd3a93fe2dd092a296f17d2dc.tar.gz
nextcloud-server-89881ed5118f282bd3a93fe2dd092a296f17d2dc.zip
Fix call to disk_free_space when a file is provided
In the case of shared files, we have to call free_space() on the file name. This has the side-effect that when uploading to a local storage without quota set, it will call disk_free_space with the file name, which fails. This fix uses the parent folder in case the given path is a file.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/storage/local.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index aa2b4628283..f6f5a8cc130 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -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;
}