From 64e3ebae74b9f47369b946fbda89a0ce6f6ffe04 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Tue, 6 Jan 2015 15:56:06 +0100
Subject: [PATCH] Add error handling to getstoragestats.php

---
 apps/files/ajax/getstoragestats.php | 6 +++++-
 lib/private/helper.php              | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php
index 4ab5b9a779c..fb7ccdc86cc 100644
--- a/apps/files/ajax/getstoragestats.php
+++ b/apps/files/ajax/getstoragestats.php
@@ -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']]);
+}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index fb4ddfae3b7..8e9b7d3b6f3 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -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;
-- 
GitLab