[Pkg-owncloud-commits] [owncloud] 28/121: Fix SharedCache::getPathById

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 16:44:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 9598efc7cd52904d36a6d91d2119013df17acd9b
Author: Robin Appelman <icewind at owncloud.com>
Date:   Wed Aug 6 13:38:14 2014 +0200

    Fix SharedCache::getPathById
---
 apps/files_sharing/lib/cache.php | 24 +++++-------------------
 lib/private/files/node/root.php  |  2 +-
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 209aa49..d0a6d4a 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -43,6 +43,7 @@ class Shared_Cache extends Cache {
 
 	/**
 	 * Get the source cache of a shared file or folder
+	 *
 	 * @param string $target Shared target file path
 	 * @return \OC\Files\Cache\Cache
 	 */
@@ -436,9 +437,8 @@ class Shared_Cache extends Cache {
 	 */
 	public function getPathById($id, $pathEnd = '') {
 		// direct shares are easy
-		$path = $this->getShareById($id);
-		if (is_string($path)) {
-			return ltrim($pathEnd, '/');
+		if ($id === $this->storage->getSourceId()) {
+			return $pathEnd;
 		} 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
 			list($parent, $name) = $this->getParentInfo($id);
@@ -452,28 +452,14 @@ class Shared_Cache extends Cache {
 
 	/**
 	 * @param integer $id
-	 */
-	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
+	 * @return array
 	 */
 	private function getParentInfo($id) {
 		$sql = 'SELECT `parent`, `name` FROM `*PREFIX*filecache` WHERE `fileid` = ?';
 		$query = \OC_DB::prepare($sql);
 		$result = $query->execute(array($id));
 		if ($row = $result->fetchRow()) {
-			return array($row['parent'], $row['name']);
+			return array((int)$row['parent'], $row['name']);
 		} else {
 			return array(-1, '');
 		}
diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php
index 2172d47..18e7a6b 100644
--- a/lib/private/files/node/root.php
+++ b/lib/private/files/node/root.php
@@ -162,7 +162,7 @@ class Root extends Folder implements Emitter {
 			if ($this->view->file_exists($fullPath)) {
 				return $this->createNode($fullPath);
 			} else {
-				throw new NotFoundException();
+				throw new NotFoundException($path);
 			}
 		} else {
 			throw new NotPermittedException();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list