mirror of
https://github.com/nextcloud/server.git
synced 2024-08-13 02:10:44 +02:00
Allow reusing FileInfo for getStorageInfo
This commit is contained in:
parent
16d10844cd
commit
da5541ac02
@ -38,7 +38,7 @@ OCP\App::setActiveNavigationEntry('files_index');
|
||||
// Load the files
|
||||
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
||||
$dir = \OC\Files\Filesystem::normalizePath($dir);
|
||||
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
|
||||
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir, false);
|
||||
// Redirect if directory does not exist
|
||||
if (!$dirInfo || !$dirInfo->getType() === 'dir') {
|
||||
header('Location: ' . OCP\Util::getScriptName() . '');
|
||||
@ -94,7 +94,7 @@ $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir
|
||||
$permissions = $dirInfo->getPermissions();
|
||||
|
||||
// information about storage capacities
|
||||
$storageInfo=OC_Helper::getStorageInfo($dir);
|
||||
$storageInfo=OC_Helper::getStorageInfo($dir, $dirInfo);
|
||||
$freeSpace=$storageInfo['free'];
|
||||
$uploadLimit=OCP\Util::uploadLimit();
|
||||
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
|
||||
|
@ -875,12 +875,15 @@ class OC_Helper {
|
||||
* Calculate the disc space for the given path
|
||||
*
|
||||
* @param string $path
|
||||
* @param \OCP\Files\FileInfo $rootInfo (optional)
|
||||
* @return array
|
||||
*/
|
||||
public static function getStorageInfo($path) {
|
||||
public static function getStorageInfo($path, $rootInfo = null) {
|
||||
// return storage info without adding mount points
|
||||
$rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
|
||||
$used = $rootInfo['size'];
|
||||
if (is_null($rootInfo)) {
|
||||
$rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
|
||||
}
|
||||
$used = $rootInfo->getSize();
|
||||
if ($used < 0) {
|
||||
$used = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user