Add error handling to getstoragestats.php

remotes/origin/fix-10825
Robin Appelman 10 years ago
parent 622c4cf779
commit 64e3ebae74

@ -10,4 +10,8 @@ OCP\JSON::checkLoggedIn();
\OC::$server->getSession()->close();
// send back json
OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics($dir)));
try {
OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics($dir)));
} catch (\OCP\Files\NotFoundException $e) {
OCP\JSON::error(['data' => ['message' => 'Folder not found']]);
}

@ -905,6 +905,9 @@ class OC_Helper {
if (!$rootInfo) {
$rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
}
if (!$rootInfo instanceof \OCP\Files\FileInfo) {
throw new \OCP\Files\NotFoundException();
}
$used = $rootInfo->getSize();
if ($used < 0) {
$used = 0;

Loading…
Cancel
Save