]> source.dussan.org Git - nextcloud-server.git/commitdiff
Root size for home storage is now size of "files" subdir
authorVincent Petry <pvince81@owncloud.com>
Mon, 18 Nov 2013 16:39:52 +0000 (17:39 +0100)
committerVincent Petry <pvince81@owncloud.com>
Mon, 18 Nov 2013 17:17:25 +0000 (18:17 +0100)
Fixes #4593

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

index 4b14bd121901e21192d2b810fcff304b69ce6a63..18dfbfe3191e7da3ae0f7c1999bf7a0895505144 100644 (file)
@@ -37,4 +37,17 @@ class HomeCache extends Cache {
                }
                return $totalSize;
        }
+
+       public function get($path) {
+               $data = parent::get($path);
+               if ($path === '' or $path === '/') {
+                       // only the size of the "files" dir counts
+                       $filesData = parent::get('files');
+
+                       if (isset($filesData['size'])) {
+                               $data['size'] = $filesData['size'];
+                       }
+               }
+               return $data;
+       }
 }
index ebf2b7270dad6579843ec8988531cd286f6a0642..2fa7f1ba92eb846e9ca8528837280f88fa478628 100644 (file)
@@ -92,4 +92,30 @@ class HomeCache extends \PHPUnit_Framework_TestCase {
                $this->assertFalse($this->cache->inCache($dir1));
                $this->assertFalse($this->cache->inCache($dir2));
        }
+
+       public function testRootFolderSizeIsFilesSize() {
+               $dir1 = 'files';
+               $afile = 'test.txt';
+               $fileData = array();
+               $fileData[''] = array('size' => 1500, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory');
+               $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory');
+               $fileData[$afile] = array('size' => 500, 'mtime' => 20);
+
+               $this->cache->put('', $fileData['']);
+               $this->cache->put($dir1, $fileData[$dir1]);
+
+               $this->assertTrue($this->cache->inCache($dir1));
+
+               // check that root size ignored the unknown sizes
+               $data = $this->cache->get('files');
+               $this->assertEquals(1000, $data['size']);
+               $data = $this->cache->get('');
+               $this->assertEquals(1000, $data['size']);
+
+               // clean up
+               $this->cache->remove('');
+               $this->cache->remove($dir1);
+
+               $this->assertFalse($this->cache->inCache($dir1));
+       }
 }