diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-07-02 18:15:58 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-07-02 18:15:58 +0200 |
commit | f4eb90e22965752616051cad0899dc55b4b69506 (patch) | |
tree | 3f7f2b53dad157185d9ad110604ea7056601881f /apps/files/ajax/list.php | |
parent | ea756a12b0dfdffe7b1bf9a69fb658ebf69db89a (diff) | |
parent | edb67f9f4dc8d3c028ba6f2d157d2174fb40aba8 (diff) | |
download | nextcloud-server-f4eb90e22965752616051cad0899dc55b4b69506.tar.gz nextcloud-server-f4eb90e22965752616051cad0899dc55b4b69506.zip |
Merge pull request #9311 from owncloud/storage-not-available
Handle storages not being available in webui and webdav
Diffstat (limited to 'apps/files/ajax/list.php')
-rw-r--r-- | apps/files/ajax/list.php | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index bae3628402f..b4641343ed4 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -2,29 +2,54 @@ OCP\JSON::checkLoggedIn(); \OC::$session->close(); +$l = OC_L10N::get('files'); // Load the files -$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; +$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)); +try { + $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) { + OCP\JSON::error(array( + 'data' => array( + 'exception' => '\OCP\Files\StorageNotAvailableException', + 'message' => $l->t('Storage not available') + ) + )); +} catch (\OCP\Files\StorageInvalidException $e) { + OCP\JSON::error(array( + 'data' => array( + 'exception' => '\OCP\Files\StorageInvalidException', + 'message' => $l->t('Storage invalid') + ) + )); +} catch (\Exception $e) { + OCP\JSON::error(array( + 'data' => array( + 'exception' => '\Exception', + 'message' => $l->t('Unknown error') + ) + )); +} |