Skip to content
Snippets Groups Projects
Commit 4526bc0b authored by Robin Appelman's avatar Robin Appelman
Browse files

Handle StorageNotAvailableException in ajax/list.php

parent d78a2a9f
No related branches found
No related tags found
No related merge requests found
<?php <?php
OCP\JSON::checkLoggedIn(); try {
\OC::$session->close(); OCP\JSON::checkLoggedIn();
\OC::$session->close();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; // Load the files
$dir = \OC\Files\Filesystem::normalizePath($dir); $dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir); $dir = \OC\Files\Filesystem::normalizePath($dir);
if (!$dirInfo || !$dirInfo->getType() === 'dir') { $dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
header("HTTP/1.0 404 Not Found"); if (!$dirInfo || !$dirInfo->getType() === 'dir') {
exit(); 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));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment