summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-06-30 16:12:12 +0200
committerRobin Appelman <icewind@owncloud.com>2014-06-30 16:12:12 +0200
commit4526bc0ba6f23a2fae5f7372d9b7702736eb46f6 (patch)
treec13a7401d01bd784bae4d7158d1bc19c3fd3a78e /apps/files/ajax
parentd78a2a9f78dc2a65bffa8f3fc4299c4540c4d5be (diff)
downloadnextcloud-server-4526bc0ba6f23a2fae5f7372d9b7702736eb46f6.tar.gz
nextcloud-server-4526bc0ba6f23a2fae5f7372d9b7702736eb46f6.zip
Handle StorageNotAvailableException in ajax/list.php
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/list.php64
1 files changed, 37 insertions, 27 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index bae3628402f..b94d00ed8f9 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -1,30 +1,40 @@
<?php
-OCP\JSON::checkLoggedIn();
-\OC::$session->close();
-
-// Load the files
-$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
-$dir = \OC\Files\Filesystem::normalizePath($dir);
-$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
-if (!$dirInfo || !$dirInfo->getType() === 'dir') {
- header("HTTP/1.0 404 Not Found");
- exit();
+try {
+ OCP\JSON::checkLoggedIn();
+ \OC::$session->close();
+
+ // Load the files
+ $dir = isset($_GET['dir']) ? $_GET['dir'] : '';
+ $dir = \OC\Files\Filesystem::normalizePath($dir);
+ $dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
+ if (!$dirInfo || !$dirInfo->getType() === 'dir') {
+ header("HTTP/1.0 404 Not Found");
+ exit();
+ }
+
+ $data = array();
+ $baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
+
+ $permissions = $dirInfo->getPermissions();
+
+ $sortAttribute = isset($_GET['sort']) ? $_GET['sort'] : 'name';
+ $sortDirection = isset($_GET['sortdirection']) ? ($_GET['sortdirection'] === 'desc') : false;
+
+ // make filelist
+
+ $files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
+ $data['directory'] = $dir;
+ $data['files'] = \OCA\Files\Helper::formatFileInfos($files);
+ $data['permissions'] = $permissions;
+
+ OCP\JSON::success(array('data' => $data));
+} catch (\OCP\Files\StorageNotAvailableException $e) {
+ $l = OC_L10N::get('files');
+ OCP\JSON::error(array(
+ 'data' => array(
+ 'exception' => '\OCP\Files\StorageNotAvailableException',
+ 'message' => $l->t('Storage not available')
+ )
+ ));
}
-
-$data = array();
-$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
-
-$permissions = $dirInfo->getPermissions();
-
-$sortAttribute = isset( $_GET['sort'] ) ? $_GET['sort'] : 'name';
-$sortDirection = isset( $_GET['sortdirection'] ) ? ($_GET['sortdirection'] === 'desc') : false;
-
-// make filelist
-$files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
-
-$data['directory'] = $dir;
-$data['files'] = \OCA\Files\Helper::formatFileInfos($files);
-$data['permissions'] = $permissions;
-
-OCP\JSON::success(array('data' => $data));