]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add error handling to getstoragestats.php
authorRobin Appelman <icewind@owncloud.com>
Tue, 6 Jan 2015 14:56:06 +0000 (15:56 +0100)
committerRobin Appelman <icewind@owncloud.com>
Tue, 6 Jan 2015 14:56:06 +0000 (15:56 +0100)
apps/files/ajax/getstoragestats.php
lib/private/helper.php

index 4ab5b9a779c6d084e95679a55394fc0976761e00..fb7ccdc86ccb371e3c63a0b0648ea3ff4ce68766 100644 (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']]);
+}
index fb4ddfae3b70d227826b7632a3261858fa79fcbd..8e9b7d3b6f32d7ade2d286593f38c846d3b2d456 100644 (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;