[Pkg-owncloud-commits] [owncloud] 13/239: use oc filesystem operations to calc the versions size. This makes sure that we can handle missing directories correctly
David Prévot
taffit at moszumanska.debian.org
Fri Nov 29 01:32:11 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 c309067c8199312de8ceb7c2eec6925bc8e34232
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Tue Nov 19 12:23:14 2013 +0100
use oc filesystem operations to calc the versions size. This makes sure that we can handle missing directories correctly
---
apps/files_versions/lib/versions.php | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 661e98b..67935fb 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -318,22 +318,23 @@ class Storage {
* @return size of vesions
*/
private static function calculateSize($uid) {
- if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
- $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
- $versionsRoot = $versions_fileview->getLocalFolder('');
-
- $iterator = new \RecursiveIteratorIterator(
- new \RecursiveDirectoryIterator($versionsRoot),
- \RecursiveIteratorIterator::CHILD_FIRST
- );
+ if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
+ $view = new \OC\Files\View('/' . $uid . '/files_versions');
$size = 0;
- foreach ($iterator as $path) {
- if ( preg_match('/^.+\.v(\d+)$/', $path, $match) ) {
- $relpath = substr($path, strlen($versionsRoot)-1);
- $size += $versions_fileview->filesize($relpath);
+ $dirContent = $view->getDirectoryContent('/');
+
+ while (!empty($dirContent)) {
+ $path = reset($dirContent);
+ if ($path['type'] === 'dir') {
+ $intPath = substr($path['path'], strlen('files_versions'));
+ $dirContent = array_merge($dirContent, $view->getDirectoryContent(substr($path['path'], strlen('files_versions'))));
+ } else {
+ $intPath = substr($path['path'], strlen('files_versions'));
+ $size += $view->filesize(substr($path['path'], strlen('files_versions')));
}
+ unset($dirContent[key($dirContent)]);
}
return $size;
--
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