summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-02-19 09:40:11 +0100
committerVincent Petry <pvince81@owncloud.com>2014-02-19 09:40:11 +0100
commite517e642befa119b77521a2e15571ee6932046ad (patch)
tree9f0cdebce503b801682eb18d4e9dd23a6bbc1971
parent1e321406ee2d973e937637ab090cbd83a6eb40cf (diff)
parentd18b9f6ea43b2a9b7bf9d2a71710edc67ec7f705 (diff)
downloadnextcloud-server-e517e642befa119b77521a2e15571ee6932046ad.tar.gz
nextcloud-server-e517e642befa119b77521a2e15571ee6932046ad.zip
Merge pull request #7257 from owncloud/filelist-fileinfo
use a FileInfo object of the directory when generting the filelist
-rw-r--r--apps/files/ajax/list.php5
-rw-r--r--apps/files/index.php5
-rw-r--r--apps/files/lib/helper.php22
-rw-r--r--lib/private/files/filesystem.php9
4 files changed, 7 insertions, 34 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 0be38c3b96f..c8286bc15ca 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -11,7 +11,8 @@ OCP\JSON::checkLoggedIn();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['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");
exit();
}
@@ -20,7 +21,7 @@ $doBreadcrumb = isset($_GET['breadcrumb']);
$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
-$permissions = \OCA\Files\Helper::getDirPermissions($dir);
+$permissions = $dirInfo->getPermissions();
// Make breadcrumb
if($doBreadcrumb) {
diff --git a/apps/files/index.php b/apps/files/index.php
index c9eea6a4174..ad7a2e210ed 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -37,8 +37,9 @@ OCP\App::setActiveNavigationEntry('files_index');
// Load the files
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
+$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
// Redirect if directory does not exist
-if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
+if (!$dirInfo->getType() === 'dir') {
header('Location: ' . OCP\Util::getScriptName() . '');
exit();
}
@@ -94,7 +95,7 @@ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
-$permissions = \OCA\Files\Helper::getDirPermissions($dir);
+$permissions = $dirInfo->getPermissions();
if ($needUpgrade) {
OCP\Util::addscript('files', 'upgrade');
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index 01fc65d76b7..ac8a2ad3200 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -112,26 +112,4 @@ class Helper
}
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;
- }
}
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index d1ebad3490c..ac9d1eac783 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -733,14 +733,7 @@ class Filesystem {
* @param string $path
* @param boolean $includeMountPoints whether to add mountpoint sizes,
* defaults to true
- * @return array
- *
- * returns an associative array with the following keys:
- * - size
- * - mtime
- * - mimetype
- * - encrypted
- * - versioned
+ * @return \OC\Files\FileInfo
*/
public static function getFileInfo($path, $includeMountPoints = true) {
return self::$defaultInstance->getFileInfo($path, $includeMountPoints);