summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-11-19 12:23:14 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2013-11-19 12:23:14 +0100
commitc309067c8199312de8ceb7c2eec6925bc8e34232 (patch)
tree3bbc3fa9cf3b8d3656e6e482bb62af74e08368db /apps/files_versions
parentb55a66187c4abed63218460b675d555f82ab9142 (diff)
downloadnextcloud-server-c309067c8199312de8ceb7c2eec6925bc8e34232.tar.gz
nextcloud-server-c309067c8199312de8ceb7c2eec6925bc8e34232.zip
use oc filesystem operations to calc the versions size. This makes sure that we can handle missing directories correctly
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/versions.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 661e98b09d5..67935fbacb5 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;