2013-11-08 06:57:28 -05:00
|
|
|
<?php
|
|
|
|
|
/**
|
2016-07-21 11:07:57 -04:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
|
*
|
2015-03-26 06:44:34 -04:00
|
|
|
* @author Andreas Fischer <bantu@owncloud.com>
|
2016-05-26 13:56:05 -04:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2020-03-31 04:49:10 -04:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2020-12-16 08:54:15 -05:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2015-03-26 06:44:34 -04:00
|
|
|
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
|
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 12:13:36 -04:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2020-12-16 08:54:15 -05:00
|
|
|
* @author Vincent Petry <vincent@nextcloud.com>
|
2015-03-26 06:44:34 -04:00
|
|
|
*
|
|
|
|
|
* @license AGPL-3.0
|
|
|
|
|
*
|
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 13:57:53 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-26 06:44:34 -04:00
|
|
|
*
|
2013-11-08 06:57:28 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\Files\Cache;
|
|
|
|
|
|
2015-12-02 08:59:13 -05:00
|
|
|
use OCP\Files\Cache\ICacheEntry;
|
|
|
|
|
|
2013-11-08 06:57:28 -05:00
|
|
|
class HomeCache extends Cache {
|
|
|
|
|
/**
|
|
|
|
|
* get the size of a folder and set it in the cache
|
|
|
|
|
*
|
|
|
|
|
* @param string $path
|
2023-03-22 14:35:05 -04:00
|
|
|
* @param array|null|ICacheEntry $entry (optional) meta data of the folder
|
2023-05-15 06:24:42 -04:00
|
|
|
* @return int|float
|
2013-11-08 06:57:28 -05:00
|
|
|
*/
|
2014-02-28 08:23:07 -05:00
|
|
|
public function calculateFolderSize($path, $entry = null) {
|
2014-05-06 07:55:26 -04:00
|
|
|
if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') {
|
2014-02-28 08:23:07 -05:00
|
|
|
return parent::calculateFolderSize($path, $entry);
|
|
|
|
|
} elseif ($path === '' or $path === '/') {
|
|
|
|
|
// since the size of / isn't used (the size of /files is used instead) there is no use in calculating it
|
|
|
|
|
return 0;
|
2023-03-09 09:25:46 -05:00
|
|
|
} else {
|
|
|
|
|
return $this->calculateFolderSizeInner($path, $entry, true);
|
2013-11-12 08:17:55 -05:00
|
|
|
}
|
2013-11-08 06:57:28 -05:00
|
|
|
}
|
2013-11-18 11:39:52 -05:00
|
|
|
|
2014-02-06 10:30:58 -05:00
|
|
|
/**
|
|
|
|
|
* @param string $path
|
2015-12-02 08:59:13 -05:00
|
|
|
* @return ICacheEntry
|
2014-02-06 10:30:58 -05:00
|
|
|
*/
|
2013-11-18 11:39:52 -05:00
|
|
|
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;
|
|
|
|
|
}
|
2013-11-08 06:57:28 -05:00
|
|
|
}
|