diff options
author | Frank Karlitschek <frank@owncloud.org> | 2013-02-19 15:18:12 -0800 |
---|---|---|
committer | Frank Karlitschek <frank@owncloud.org> | 2013-02-19 15:18:12 -0800 |
commit | 38782036798dbe0a34995a3fca0aa92583cb9099 (patch) | |
tree | a999e79775f1e539ff9fb0d55e346721b4b0740d | |
parent | 99758dce2b9e014081c27ff35b1df9e16f9eb430 (diff) | |
parent | 451daf3ab14edde76f4d04e6fe41519cf517fe47 (diff) | |
download | nextcloud-server-38782036798dbe0a34995a3fca0aa92583cb9099.tar.gz nextcloud-server-38782036798dbe0a34995a3fca0aa92583cb9099.zip |
Merge pull request #1731 from owncloud/unknown-freespace
Give storage backends the option to define having no known free space
-rw-r--r-- | apps/files/ajax/upload.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/amazons3.php | 5 | ||||
-rw-r--r-- | apps/files_external/lib/sftp.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/streamwrapper.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/swift.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/webdav.php | 2 | ||||
-rw-r--r-- | lib/fileproxy/quota.php | 15 | ||||
-rw-r--r-- | lib/files/filesystem.php | 2 | ||||
-rw-r--r-- | lib/files/storage/common.php | 9 | ||||
-rw-r--r-- | lib/helper.php | 8 |
10 files changed, 28 insertions, 27 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 07977f5ddf1..9031c729eff 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -48,7 +48,7 @@ $totalSize = 0; foreach ($files['size'] as $size) { $totalSize += $size; } -if ($totalSize > \OC\Files\Filesystem::free_space($dir)) { +if ($totalSize > $maxUploadFilesize) { OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'), 'uploadMaxFilesize' => $maxUploadFilesize, 'maxHumanFilesize' => $maxHumanFilesize))); diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 494885a1dd3..37e53a3a670 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -229,11 +229,6 @@ class AmazonS3 extends \OC\Files\Storage\Common { return false; } - public function free_space($path) { - // Infinite? - return false; - } - public function touch($path, $mtime = null) { if (is_null($mtime)) { $mtime = time(); diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 3527f50ec98..785eb7dfc42 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -242,10 +242,6 @@ class SFTP extends \OC\Files\Storage\Common { } } - public function free_space($path) { - return -1; - } - public function touch($path, $mtime=null) { try { if (!is_null($mtime)) return false; diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index a631e7ce06a..4685877f26b 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -76,10 +76,6 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{ return fopen($this->constructUrl($path), $mode); } - public function free_space($path) { - return 0; - } - public function touch($path, $mtime=null) { $this->init(); if(is_null($mtime)) { diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 0fd6fa143b8..a00316c1f84 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -478,10 +478,6 @@ class SWIFT extends \OC\Files\Storage\Common{ } } - public function free_space($path) { - return 1024*1024*1024*8; - } - public function touch($path, $mtime=null) { $this->init(); $obj=$this->getObject($path); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 039a07b1ef2..91cc22779e6 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -222,7 +222,7 @@ class DAV extends \OC\Files\Storage\Common{ return 0; } } catch(\Exception $e) { - return 0; + return \OC\Files\FREE_SPACE_UNKNOWN; } } diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php index 07d1d250e4d..3dac3264fbe 100644 --- a/lib/fileproxy/quota.php +++ b/lib/fileproxy/quota.php @@ -62,21 +62,21 @@ class OC_FileProxy_Quota extends OC_FileProxy{ * @var string $internalPath */ list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path); - $owner=$storage->getOwner($internalPath); + $owner = $storage->getOwner($internalPath); if (!$owner) { return -1; } - $totalSpace=$this->getQuota($owner); - if($totalSpace==-1) { + $totalSpace = $this->getQuota($owner); + if($totalSpace == -1) { return -1; } $view = new \OC\Files\View("/".$owner."/files"); - $rootInfo=$view->getFileInfo('/'); - $usedSpace=isset($rootInfo['size'])?$rootInfo['size']:0; - return $totalSpace-$usedSpace; + $rootInfo = $view->getFileInfo('/'); + $usedSpace = isset($rootInfo['size'])?$rootInfo['size']:0; + return $totalSpace - $usedSpace; } public function postFree_space($path, $space) { @@ -84,6 +84,9 @@ class OC_FileProxy_Quota extends OC_FileProxy{ if($free==-1) { return $space; } + if ($space < 0){ + return $free; + } return min($free, $space); } diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index cba469e06c4..875a9d6c5ee 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -29,6 +29,8 @@ namespace OC\Files; +const FREE_SPACE_UNKNOWN = -2; + class Filesystem { public static $loaded = false; /** diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 4cdabf1c8a6..4e7a73e5d4a 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -301,4 +301,13 @@ abstract class Common implements \OC\Files\Storage\Storage { } return implode('/', $output); } + + /** + * get the free space in the storage + * @param $path + * return int + */ + public function free_space($path){ + return \OC\Files\FREE_SPACE_UNKNOWN; + } } diff --git a/lib/helper.php b/lib/helper.php index 0f810ffc0c2..add5c66e7be 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -762,9 +762,13 @@ class OC_Helper { $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace = \OC\Files\Filesystem::free_space($dir); - $freeSpace = max($freeSpace, 0); + if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){ + $freeSpace = max($freeSpace, 0); - return min($maxUploadFilesize, $freeSpace); + return min($maxUploadFilesize, $freeSpace); + } else { + return $maxUploadFilesize; + } } /** |