]> source.dussan.org Git - nextcloud-server.git/commitdiff
Give storage backends the option to define having no known free space
authorRobin Appelman <icewind@owncloud.com>
Sat, 16 Feb 2013 02:27:50 +0000 (03:27 +0100)
committerRobin Appelman <icewind@owncloud.com>
Sat, 16 Feb 2013 02:27:50 +0000 (03:27 +0100)
When this is the case only the configured max upload size is taking into account for uploading

apps/files/ajax/upload.php
apps/files_external/lib/amazons3.php
apps/files_external/lib/sftp.php
apps/files_external/lib/streamwrapper.php
apps/files_external/lib/swift.php
apps/files_external/lib/webdav.php
lib/files/filesystem.php
lib/files/storage/common.php
lib/helper.php

index 07977f5ddf1ddb04972bd027b903429889dc04db..9031c729eff09408079469e502c32c903a254bd1 100644 (file)
@@ -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)));
index 494885a1dd3f3d1d69a097730d8fc1a3ab40885f..37e53a3a6701886a3d270bb731c6746262674d90 100644 (file)
@@ -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();
index 551a5a64ef2f6e32347c32f28d59f54683ce9523..77c08d3b733fbf649fc655c00bb2457597fd135b 100644 (file)
@@ -241,10 +241,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;
index a631e7ce06aafbb1c7369135cbe42484b741c5b3..4685877f26b7ea0bb0d7266bfceb897afa08f809 100644 (file)
@@ -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)) {
index 0fd6fa143b816dff602231767ae57fe7b2e51cd1..a00316c1f844a4ea8d6b17cc0423c366cce296f0 100644 (file)
@@ -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);
index 039a07b1ef2a9b4a9229ddc59fb9c61a12e1cd9a..91cc22779e69c67b368fc09878e87fb52dfb62fa 100644 (file)
@@ -222,7 +222,7 @@ class DAV extends \OC\Files\Storage\Common{
                                return 0;
                        }
                } catch(\Exception $e) {
-                       return 0;
+                       return \OC\Files\FREE_SPACE_UNKNOWN;
                }
        }
 
index f45308680777d81fc39676f77cbb28806d1fa7ce..0dafef836bd9fed3d4542231dccfe849f07aeb0c 100644 (file)
@@ -29,6 +29,8 @@
 
 namespace OC\Files;
 
+const FREE_SPACE_UNKNOWN = -2;
+
 class Filesystem {
        public static $loaded = false;
        /**
index 4cdabf1c8a6ebc59c908bbb8379b01250f2735b7..4e7a73e5d4acb0b55be1aae625023079adc7abd5 100644 (file)
@@ -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;
+       }
 }
index 0f810ffc0c2dc885749a6992ad9eaf43f9006fa2..add5c66e7bee236c9f4546ffdc944172431bf192 100644 (file)
@@ -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;
+               }
        }
 
        /**