Skip to content
Snippets Groups Projects
Commit faf14b4c authored by Morris Jobke's avatar Morris Jobke
Browse files

Merge pull request #5937 from owncloud/calc_version_size

use oc filesystem operations to calc the versions size
parents 5310a592 46dff067
No related branches found
No related tags found
No related merge requests found
......@@ -319,21 +319,20 @@ class Storage {
*/
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
);
$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') {
$dirContent = array_merge($dirContent, $view->getDirectoryContent(substr($path['path'], strlen('files_versions'))));
} else {
$size += $view->filesize(substr($path['path'], strlen('files_versions')));
}
unset($dirContent[key($dirContent)]);
}
return $size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment