]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix size propagation over shared storage boundary
authorVincent Petry <pvince81@owncloud.com>
Thu, 5 Mar 2015 21:23:47 +0000 (22:23 +0100)
committerVincent Petry <pvince81@owncloud.com>
Fri, 13 Mar 2015 10:09:36 +0000 (11:09 +0100)
apps/files_sharing/lib/cache.php

index c1ef50300915421b34fdc6ebf652b029ed52e16c..57e09c979ac9d42d2d0a0c8e26ea8befe404644c 100644 (file)
@@ -345,6 +345,28 @@ class Shared_Cache extends Cache {
                return $result;
        }
 
+       /**
+        * update the folder size and the size of all parent folders
+        *
+        * @param string|boolean $path
+        * @param array $data (optional) meta data of the folder
+        */
+       public function correctFolderSize($path, $data = null) {
+               $this->calculateFolderSize($path, $data);
+               if ($path !== '') {
+                       $parent = dirname($path);
+                       if ($parent === '.' or $parent === '/') {
+                               $parent = '';
+                       }
+                       $this->correctFolderSize($parent);
+               } else {
+                       // bubble up to source cache
+                       $sourceCache = $this->getSourceCache($path);
+                       $parent = dirname($this->files[$path]);
+                       $sourceCache->correctFolderSize($parent);
+               }
+       }
+
        /**
         * get the size of a folder and set it in the cache
         *