]> source.dussan.org Git - nextcloud-server.git/commitdiff
use a FileInfo object of the directory when generting the filelist
authorRobin Appelman <icewind@owncloud.com>
Tue, 18 Feb 2014 14:39:35 +0000 (15:39 +0100)
committerRobin Appelman <icewind@owncloud.com>
Tue, 18 Feb 2014 14:39:35 +0000 (15:39 +0100)
apps/files/ajax/list.php
apps/files/index.php
apps/files/lib/helper.php
lib/private/files/filesystem.php

index 0be38c3b96f6749fd04deded1595e95079fd26aa..c8286bc15ca2fbef22e623195b2d9ad8a90831ec 100644 (file)
@@ -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) {
index dd63f29bc28aaf28249dab4c5b8fa879b42baf3a..f8f1618e7875554b819bd52dd60e8b9bc5f7171b 100644 (file)
@@ -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();
 }
@@ -92,7 +93,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');
index 01fc65d76b74444a8d4c18801557250dc1502012..ac8a2ad320051f32da7f4080e40608b45ae33927 100644 (file)
@@ -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;
-       }
 }
index a83e9aa86d24b8ccc8fe714539e741fbaf1bcd44..aa7f632c5f743a99e8831597c8e5fe52ae761b8d 100644 (file)
@@ -727,14 +727,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);