Fix FileInfo->getType errors

This commit is contained in:
Robin Appelman 2014-03-07 14:52:44 +01:00
parent 1785c0c9b9
commit 65f52fee4f
2 changed files with 9 additions and 2 deletions

View 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(){

View 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