summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/ajax/delete.php7
-rw-r--r--apps/files/lib/helper.php19
2 files changed, 18 insertions, 8 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 61caa7618da..1a810f6954c 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -36,7 +36,12 @@ foreach ($files as $file) {
}
// get array with updated storage stats (e.g. max file size) after upload
-$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
+try {
+ $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
+} catch(\OCP\Files\NotFoundException $e) {
+ OCP\JSON::error(['data' => ['message' => 'File not found']]);
+ return;
+}
if ($success) {
OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats)));
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index 84b1a0f1662..bcca6f0a276 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -13,21 +13,26 @@ use OCP\Files\FileInfo;
/**
* Helper class for manipulating file information
*/
-class Helper
-{
+class Helper {
+ /**
+ * @param string $dir
+ * @return array
+ * @throws \OCP\Files\NotFoundException
+ */
public static function buildFileStorageStatistics($dir) {
// information about storage capacities
$storageInfo = \OC_Helper::getStorageInfo($dir);
-
$l = new \OC_L10N('files');
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
- return array('uploadMaxFilesize' => $maxUploadFileSize,
- 'maxHumanFilesize' => $maxHumanFileSize,
- 'freeSpace' => $storageInfo['free'],
- 'usedSpacePercent' => (int)$storageInfo['relative']);
+ return [
+ 'uploadMaxFilesize' => $maxUploadFileSize,
+ 'maxHumanFilesize' => $maxHumanFileSize,
+ 'freeSpace' => $storageInfo['free'],
+ 'usedSpacePercent' => (int)$storageInfo['relative']
+ ];
}
/**