]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix FileInfo->getType errors
authorRobin Appelman <icewind@owncloud.com>
Fri, 7 Mar 2014 13:52:44 +0000 (14:52 +0100)
committerRobin Appelman <icewind@owncloud.com>
Fri, 7 Mar 2014 13:52:44 +0000 (14:52 +0100)
lib/private/files/fileinfo.php
lib/public/files/fileinfo.php

index 2dbdd80a26bb66da9a915d2da76f3234e22d6b76..a9e64fe15334ae5a871ea5c522cadd4e253f9629 100644 (file)
@@ -53,6 +53,9 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
        }
 
        public function offsetGet($offset) {
+               if ($offset === 'type') {
+                       return $this->getType();
+               }
                return $this->data[$offset];
        }
 
@@ -144,7 +147,11 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
         * @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER
         */
        public function getType() {
-               return $this->data['type'];
+               if (isset($this->data['type'])) {
+                       return $this->data['type'];
+               } else {
+                       return $this->getMimetype() === 'httpd/unix-directory' ? self::TYPE_FOLDER : self::TYPE_FILE;
+               }
        }
 
        public function getData(){
index 68ce45d3fa151b57e711bb9344df740738025799..37162e09336ea79272a376df67ae7e6164ea0268 100644 (file)
@@ -9,7 +9,7 @@ namespace OCP\Files;
 
 interface FileInfo {
        const TYPE_FILE = 'file';
-       const TYPE_FOLDER = 'folder';
+       const TYPE_FOLDER = 'dir';
 
        /**
         * Get the Etag of the file or folder