Add error handling to getstoragestats.php

This commit is contained in:
Robin Appelman 2015-01-06 15:56:06 +01:00
parent 622c4cf779
commit 64e3ebae74
2 changed files with 8 additions and 1 deletions

View File

@ -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']]);
}

View File

@ -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;