[Pkg-owncloud-commits] [owncloud] 81/111: Root size for home storage is now size of "files" subdir

David Prévot taffit at moszumanska.debian.org
Wed Nov 20 21:38:45 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 3e2fd9942b4c0c3d8109a28d01dafdf830553609
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Mon Nov 18 17:39:52 2013 +0100

    Root size for home storage is now size of "files" subdir
    
    Fixes #4593
---
 lib/private/files/cache/homecache.php |   13 +++++++++++++
 tests/lib/files/cache/homecache.php   |   26 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/lib/private/files/cache/homecache.php b/lib/private/files/cache/homecache.php
index 4b14bd1..18dfbfe 100644
--- a/lib/private/files/cache/homecache.php
+++ b/lib/private/files/cache/homecache.php
@@ -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;
+	}
 }
diff --git a/tests/lib/files/cache/homecache.php b/tests/lib/files/cache/homecache.php
index ebf2b72..2fa7f1b 100644
--- a/tests/lib/files/cache/homecache.php
+++ b/tests/lib/files/cache/homecache.php
@@ -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));
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list