return -1;
}
+ /**
+ * check if a file is available in the cache
+ *
+ * @param string $file
+ * @return bool
+ */
+ public function inCache($file) {
+ if ($file == '') {
+ return true;
+ }
+ return parent::inCache($file);
+ }
+
/**
* remove a file or folder from the cache
*
if ($fileId == -1) {
return \OCP\PERMISSION_READ;
}
- $source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
+ $source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE, null, true);
if ($source) {
return $source['permissions'];
} else {
}
public static function getSource($target) {
+ if ($target == '') {
+ return false;
+ }
$target = '/'.$target;
$target = rtrim($target, '/');
$pos = strpos($target, '/', 1);
public function getChildren($itemSource) {
$children = array();
$parents = array($itemSource);
+ $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
+ $result = $query->execute(array('httpd/unix-directory'));
+ if ($row = $result->fetchRow()) {
+ $mimetype = $row['id'];
+ } else {
+ $mimetype = -1;
+ }
while (!empty($parents)) {
$parents = "'".implode("','", $parents)."'";
$query = OC_DB::prepare('SELECT `fileid`, `name`, `mimetype` FROM `*PREFIX*filecache` WHERE `parent` IN ('.$parents.')');
while ($file = $result->fetchRow()) {
$children[] = array('source' => $file['fileid'], 'file_path' => $file['name']);
// If a child folder is found look inside it
- if ($file['mimetype'] == 'httpd/unix-directory') {
- $parents[] = $file['id'];
+ if ($file['mimetype'] == $mimetype) {
+ $parents[] = $file['fileid'];
}
}
}
}
public function getScanner($path = '') {
- if ($path != '' && ($source = $this->getSourcePath($path))) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- if ($storage) {
- return $storage->getScanner($internalPath);
- }
- }
return new \OC\Files\Cache\Scanner($this);
}
$collectionItems = array();
foreach ($items as &$row) {
// Return only the item instead of a 2-dimensional array
- if ($limit == 1 && $row['item_type'] == $itemType && $row[$column] == $item) {
+ if ($limit == 1 && $row[$column] == $item && ($row['item_type'] == $itemType || $itemType == 'file')) {
if ($format == self::FORMAT_NONE) {
return $row;
} else {
if (!empty($collectionItems)) {
$items = array_merge($items, $collectionItems);
}
+ if (empty($items) && $limit == 1) {
+ return false;
+ }
if ($format == self::FORMAT_NONE) {
return $items;
} else if ($format == self::FORMAT_STATUSES) {