]> source.dussan.org Git - nextcloud-server.git/commitdiff
Now also preventing to override "files" dir size with -1
authorVincent Petry <pvince81@owncloud.com>
Tue, 7 Jan 2014 16:41:04 +0000 (17:41 +0100)
committerVincent Petry <pvince81@owncloud.com>
Tue, 7 Jan 2014 21:34:01 +0000 (22:34 +0100)
Fixes #6526

lib/private/files/cache/homecache.php
tests/lib/files/cache/homecache.php

index 18dfbfe3191e7da3ae0f7c1999bf7a0895505144..71bb944da71c9e38abdf70da3a76c8b979cef43c 100644 (file)
@@ -16,7 +16,7 @@ class HomeCache extends Cache {
         * @return int
         */
        public function calculateFolderSize($path) {
-               if ($path !== '/' and $path !== '') {
+               if ($path !== '/' and $path !== '' and $path !== 'files') {
                        return parent::calculateFolderSize($path);
                }
 
index 2fa7f1ba92eb846e9ca8528837280f88fa478628..87fd0dba4c6466e383731b02d508dd5927b7620f 100644 (file)
@@ -62,33 +62,39 @@ class HomeCache extends \PHPUnit_Framework_TestCase {
        }
 
        /**
-        * Tests that the root folder size calculation ignores the subdirs that have an unknown
-        * size. This makes sure that quota calculation still works as it's based on the root
-        * folder size.
+        * Tests that the root and files folder size calculation ignores the subdirs
+        * that have an unknown size. This makes sure that quota calculation still
+        * works as it's based on the "files" folder size.
         */
        public function testRootFolderSizeIgnoresUnknownUpdate() {
-               $dir1 = 'knownsize';
-               $dir2 = 'unknownsize';
+               $dir1 = 'files/knownsize';
+               $dir2 = 'files/unknownsize';
                $fileData = array();
                $fileData[''] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory');
+               $fileData['files'] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory');
                $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory');
                $fileData[$dir2] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory');
 
                $this->cache->put('', $fileData['']);
+               $this->cache->put('files', $fileData['files']);
                $this->cache->put($dir1, $fileData[$dir1]);
                $this->cache->put($dir2, $fileData[$dir2]);
 
+               $this->assertTrue($this->cache->inCache('files'));
                $this->assertTrue($this->cache->inCache($dir1));
                $this->assertTrue($this->cache->inCache($dir2));
 
-               // check that root size ignored the unknown sizes
+               // check that files and root size ignored the unknown sizes
+               $this->assertEquals(1000, $this->cache->calculateFolderSize('files'));
                $this->assertEquals(1000, $this->cache->calculateFolderSize(''));
 
                // clean up
                $this->cache->remove('');
+               $this->cache->remove('files');
                $this->cache->remove($dir1);
                $this->cache->remove($dir2);
 
+               $this->assertFalse($this->cache->inCache('files'));
                $this->assertFalse($this->cache->inCache($dir1));
                $this->assertFalse($this->cache->inCache($dir2));
        }