use a FileInfo object of the directory when generting the filelist
This commit is contained in:
parent
92560c5b86
commit
d18b9f6ea4
|
@ -11,7 +11,8 @@ OCP\JSON::checkLoggedIn();
|
||||||
// Load the files
|
// Load the files
|
||||||
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
|
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
|
||||||
$dir = \OC\Files\Filesystem::normalizePath($dir);
|
$dir = \OC\Files\Filesystem::normalizePath($dir);
|
||||||
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
|
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
|
||||||
|
if (!$dirInfo->getType() === 'dir') {
|
||||||
header("HTTP/1.0 404 Not Found");
|
header("HTTP/1.0 404 Not Found");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +21,7 @@ $doBreadcrumb = isset($_GET['breadcrumb']);
|
||||||
$data = array();
|
$data = array();
|
||||||
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
|
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
|
||||||
|
|
||||||
$permissions = \OCA\Files\Helper::getDirPermissions($dir);
|
$permissions = $dirInfo->getPermissions();
|
||||||
|
|
||||||
// Make breadcrumb
|
// Make breadcrumb
|
||||||
if($doBreadcrumb) {
|
if($doBreadcrumb) {
|
||||||
|
|
|
@ -37,8 +37,9 @@ OCP\App::setActiveNavigationEntry('files_index');
|
||||||
// Load the files
|
// Load the files
|
||||||
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
||||||
$dir = \OC\Files\Filesystem::normalizePath($dir);
|
$dir = \OC\Files\Filesystem::normalizePath($dir);
|
||||||
|
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
|
||||||
// Redirect if directory does not exist
|
// Redirect if directory does not exist
|
||||||
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
|
if (!$dirInfo->getType() === 'dir') {
|
||||||
header('Location: ' . OCP\Util::getScriptName() . '');
|
header('Location: ' . OCP\Util::getScriptName() . '');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,7 @@ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
|
||||||
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
|
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
|
||||||
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
|
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
|
||||||
|
|
||||||
$permissions = \OCA\Files\Helper::getDirPermissions($dir);
|
$permissions = $dirInfo->getPermissions();
|
||||||
|
|
||||||
if ($needUpgrade) {
|
if ($needUpgrade) {
|
||||||
OCP\Util::addscript('files', 'upgrade');
|
OCP\Util::addscript('files', 'upgrade');
|
||||||
|
|
|
@ -112,26 +112,4 @@ class Helper
|
||||||
}
|
}
|
||||||
return $breadcrumb;
|
return $breadcrumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the numeric permissions for the given directory.
|
|
||||||
* @param string $dir directory without trailing slash
|
|
||||||
* @return numeric permissions
|
|
||||||
*/
|
|
||||||
public static function getDirPermissions($dir){
|
|
||||||
$permissions = \OCP\PERMISSION_READ;
|
|
||||||
if (\OC\Files\Filesystem::isCreatable($dir . '/')) {
|
|
||||||
$permissions |= \OCP\PERMISSION_CREATE;
|
|
||||||
}
|
|
||||||
if (\OC\Files\Filesystem::isUpdatable($dir . '/')) {
|
|
||||||
$permissions |= \OCP\PERMISSION_UPDATE;
|
|
||||||
}
|
|
||||||
if (\OC\Files\Filesystem::isDeletable($dir . '/')) {
|
|
||||||
$permissions |= \OCP\PERMISSION_DELETE;
|
|
||||||
}
|
|
||||||
if (\OC\Files\Filesystem::isSharable($dir . '/')) {
|
|
||||||
$permissions |= \OCP\PERMISSION_SHARE;
|
|
||||||
}
|
|
||||||
return $permissions;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -727,14 +727,7 @@ class Filesystem {
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param boolean $includeMountPoints whether to add mountpoint sizes,
|
* @param boolean $includeMountPoints whether to add mountpoint sizes,
|
||||||
* defaults to true
|
* defaults to true
|
||||||
* @return array
|
* @return \OC\Files\FileInfo
|
||||||
*
|
|
||||||
* returns an associative array with the following keys:
|
|
||||||
* - size
|
|
||||||
* - mtime
|
|
||||||
* - mimetype
|
|
||||||
* - encrypted
|
|
||||||
* - versioned
|
|
||||||
*/
|
*/
|
||||||
public static function getFileInfo($path, $includeMountPoints = true) {
|
public static function getFileInfo($path, $includeMountPoints = true) {
|
||||||
return self::$defaultInstance->getFileInfo($path, $includeMountPoints);
|
return self::$defaultInstance->getFileInfo($path, $includeMountPoints);
|
||||||
|
|
Loading…
Reference in New Issue