Skip to content
Snippets Groups Projects
Commit 8a10c44e authored by Vincent Petry's avatar Vincent Petry
Browse files

Merge pull request #8015 from owncloud/storageinfo-reuse

Allow reusing FileInfo for getStorageInfo
parents 0805f678 da5541ac
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ OCP\App::setActiveNavigationEntry('files_index'); ...@@ -39,7 +39,7 @@ OCP\App::setActiveNavigationEntry('files_index');
// Load the files // Load the files
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : ''; $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
$dir = \OC\Files\Filesystem::normalizePath($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 // Redirect if directory does not exist
if (!$dirInfo || !$dirInfo->getType() === 'dir') { if (!$dirInfo || !$dirInfo->getType() === 'dir') {
header('Location: ' . OCP\Util::getScriptName() . ''); header('Location: ' . OCP\Util::getScriptName() . '');
...@@ -70,7 +70,7 @@ $config = \OC::$server->getConfig(); ...@@ -70,7 +70,7 @@ $config = \OC::$server->getConfig();
$permissions = $dirInfo->getPermissions(); $permissions = $dirInfo->getPermissions();
// information about storage capacities // information about storage capacities
$storageInfo=OC_Helper::getStorageInfo($dir); $storageInfo=OC_Helper::getStorageInfo($dir, $dirInfo);
$freeSpace=$storageInfo['free']; $freeSpace=$storageInfo['free'];
$uploadLimit=OCP\Util::uploadLimit(); $uploadLimit=OCP\Util::uploadLimit();
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir, $freeSpace); $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir, $freeSpace);
......
...@@ -875,12 +875,15 @@ class OC_Helper { ...@@ -875,12 +875,15 @@ class OC_Helper {
* Calculate the disc space for the given path * Calculate the disc space for the given path
* *
* @param string $path * @param string $path
* @param \OCP\Files\FileInfo $rootInfo (optional)
* @return array * @return array
*/ */
public static function getStorageInfo($path) { public static function getStorageInfo($path, $rootInfo = null) {
// return storage info without adding mount points // return storage info without adding mount points
if (is_null($rootInfo)) {
$rootInfo = \OC\Files\Filesystem::getFileInfo($path, false); $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
$used = $rootInfo['size']; }
$used = $rootInfo->getSize();
if ($used < 0) { if ($used < 0) {
$used = 0; $used = 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment