Fix SharedCache::getPathById
This commit is contained in:
parent
1deb6aadd3
commit
12207ec0c7
|
@ -43,6 +43,7 @@ class Shared_Cache extends Cache {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the source cache of a shared file or folder
|
* Get the source cache of a shared file or folder
|
||||||
|
*
|
||||||
* @param string $target Shared target file path
|
* @param string $target Shared target file path
|
||||||
* @return \OC\Files\Cache\Cache
|
* @return \OC\Files\Cache\Cache
|
||||||
*/
|
*/
|
||||||
|
@ -275,7 +276,7 @@ class Shared_Cache extends Cache {
|
||||||
*/
|
*/
|
||||||
public function search($pattern) {
|
public function search($pattern) {
|
||||||
|
|
||||||
$pattern = trim($pattern,'%');
|
$pattern = trim($pattern, '%');
|
||||||
|
|
||||||
$normalizedPattern = $this->normalize($pattern);
|
$normalizedPattern = $this->normalize($pattern);
|
||||||
|
|
||||||
|
@ -403,9 +404,8 @@ class Shared_Cache extends Cache {
|
||||||
*/
|
*/
|
||||||
public function getPathById($id, $pathEnd = '') {
|
public function getPathById($id, $pathEnd = '') {
|
||||||
// direct shares are easy
|
// direct shares are easy
|
||||||
$path = $this->getShareById($id);
|
if ($id === $this->storage->getSourceId()) {
|
||||||
if (is_string($path)) {
|
return $pathEnd;
|
||||||
return ltrim($pathEnd, '/');
|
|
||||||
} else {
|
} else {
|
||||||
// if the item is a direct share we try and get the path of the parent and append the name of the item to it
|
// if the item is a direct share we try and get the path of the parent and append the name of the item to it
|
||||||
list($parent, $name) = $this->getParentInfo($id);
|
list($parent, $name) = $this->getParentInfo($id);
|
||||||
|
@ -419,28 +419,14 @@ class Shared_Cache extends Cache {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
*/
|
* @return array
|
||||||
private function getShareById($id) {
|
|
||||||
$item = \OCP\Share::getItemSharedWithBySource('file', $id);
|
|
||||||
if ($item) {
|
|
||||||
return trim($item['file_target'], '/');
|
|
||||||
}
|
|
||||||
$item = \OCP\Share::getItemSharedWithBySource('folder', $id);
|
|
||||||
if ($item) {
|
|
||||||
return trim($item['file_target'], '/');
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param integer $id
|
|
||||||
*/
|
*/
|
||||||
private function getParentInfo($id) {
|
private function getParentInfo($id) {
|
||||||
$sql = 'SELECT `parent`, `name` FROM `*PREFIX*filecache` WHERE `fileid` = ?';
|
$sql = 'SELECT `parent`, `name` FROM `*PREFIX*filecache` WHERE `fileid` = ?';
|
||||||
$query = \OC_DB::prepare($sql);
|
$query = \OC_DB::prepare($sql);
|
||||||
$result = $query->execute(array($id));
|
$result = $query->execute(array($id));
|
||||||
if ($row = $result->fetchRow()) {
|
if ($row = $result->fetchRow()) {
|
||||||
return array($row['parent'], $row['name']);
|
return array((int)$row['parent'], $row['name']);
|
||||||
} else {
|
} else {
|
||||||
return array(-1, '');
|
return array(-1, '');
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ class Root extends Folder implements Emitter {
|
||||||
if ($this->view->file_exists($fullPath)) {
|
if ($this->view->file_exists($fullPath)) {
|
||||||
return $this->createNode($fullPath);
|
return $this->createNode($fullPath);
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException($path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new NotPermittedException();
|
throw new NotPermittedException();
|
||||||
|
|
Loading…
Reference in New Issue