2013-11-08 06:57:28 -05:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2013-11-08 06:57:28 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
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) {
|
2025-09-27 16:56:38 -04:00
|
|
|
if ($path !== '/' && $path !== '' && $path !== 'files' && $path !== 'files_trashbin' && $path !== 'files_versions') {
|
2014-02-28 08:23:07 -05:00
|
|
|
return parent::calculateFolderSize($path, $entry);
|
2025-09-27 16:56:38 -04:00
|
|
|
} elseif ($path === '' || $path === '/') {
|
2014-02-28 08:23:07 -05:00
|
|
|
// 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
|
|
|
/**
|
2023-04-03 02:29:33 -04:00
|
|
|
* @param string $file
|
2015-12-02 08:59:13 -05:00
|
|
|
* @return ICacheEntry
|
2014-02-06 10:30:58 -05:00
|
|
|
*/
|
2023-04-03 02:29:33 -04:00
|
|
|
public function get($file) {
|
|
|
|
|
$data = parent::get($file);
|
2025-09-27 16:56:38 -04:00
|
|
|
if ($file === '' || $file === '/') {
|
2013-11-18 11:39:52 -05:00
|
|
|
// 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
|
|
|
}
|