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 | |
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')
-rw-r--r-- | apps/files/ajax/list.php | 69 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 23 |
2 files changed, 59 insertions, 33 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') + ) + )); +} diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c7fccc5dd66..94f161943a1 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -846,13 +846,18 @@ * @param {boolean} force set to true to force changing directory */ changeDirectory: function(targetDir, changeUrl, force) { + var self = this; var currentDir = this.getCurrentDirectory(); targetDir = targetDir || '/'; if (!force && currentDir === targetDir) { return; } this._setCurrentDir(targetDir, changeUrl); - this.reload(); + this.reload().then(function(success){ + if (!success) { + self.changeDirectory(currentDir, true); + } + }); }, linkTo: function(dir) { return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); @@ -912,7 +917,6 @@ * @brief Reloads the file list using ajax call */ reload: function() { - var self = this; this._selectedFiles = {}; this._selectionSummary.clear(); this.$el.find('.select-all').prop('checked', false); @@ -926,14 +930,10 @@ dir : this.getCurrentDirectory(), sort: this._sort, sortdirection: this._sortDirection - }, - error: function(result) { - self.reloadCallback(result); - }, - success: function(result) { - self.reloadCallback(result); } }); + var callBack = this.reloadCallback.bind(this); + return this._reloadCall.then(callBack, callBack); }, reloadCallback: function(result) { delete this._reloadCall; @@ -941,17 +941,17 @@ if (!result || result.status === 'error') { OC.Notification.show(result.data.message); - return; + return false; } if (result.status === 404) { // go back home this.changeDirectory('/'); - return; + return false; } // aborted ? if (result.status === 0){ - return; + return true; } // TODO: should rather return upload file size through @@ -963,6 +963,7 @@ } this.setFiles(result.data.files); + return true }, updateStorageStatistics: function(force) { |