]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding size() to the file cache
authorThomas Müller <thomas.mueller@tmit.eu>
Mon, 16 Sep 2013 08:43:53 +0000 (10:43 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 16 Sep 2013 08:43:53 +0000 (10:43 +0200)
lib/cache/file.php

index 361138e47362138295c67873ca611aa26c12fd55..eed2637c9816687a3739acdeb2bdc22689b0c067 100644 (file)
@@ -40,6 +40,24 @@ class OC_Cache_File{
                return $result;
        }
 
+       /**
+        * Returns the size of the stored/cached data
+        *
+        * @param $key
+        * @return int
+        */
+       public function size($key) {
+               $result = 0;
+               $proxyStatus = \OC_FileProxy::$enabled;
+               \OC_FileProxy::$enabled = false;
+               if ($this->hasKey($key)) {
+                       $storage = $this->getStorage();
+                       $result = $storage->filesize($key);
+               }
+               \OC_FileProxy::$enabled = $proxyStatus;
+               return $result;
+       }
+
        public function set($key, $value, $ttl=0) {
                $storage = $this->getStorage();
                $result = false;