[Pkg-owncloud-commits] [owncloud] 02/394: Shared files are not stored in the file cache. Therefore we need to use the share table from the db to find the item source if the public link re-shares a already shared file.

David Prévot taffit at alioth.debian.org
Fri Nov 8 23:11:12 UTC 2013


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

taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.

commit 3b9c10dcf61fb633acc80f26b1ee151b6429589e
Author: Björn Schießle <schiessle at owncloud.com>
Date:   Wed Oct 24 12:48:58 2012 +0200

    Shared files are not stored in the file cache. Therefore we need to
    use the share table from the db to find the item source if the public
    link re-shares a already shared file.
---
 apps/files_sharing/public.php |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index 9e3caab..47e8ab7 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -21,6 +21,23 @@ if (isset($_GET['token'])) {
 }
 // Enf of backward compatibility
 
+function getID($path) {
+	// use the share table from the db to find the item source if the file was reshared because shared files are not stored in the file cache.
+	if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") {
+		$path_parts = explode('/', $path, 5);
+		$user = $path_parts[1];
+		$intPath = '/'.$path_parts[4];
+		$query = \OC_DB::prepare('SELECT item_source FROM *PREFIX*share WHERE uid_owner = ? AND file_target = ? ');
+		$result = $query->execute(array($user, $intPath));
+		$row = $result->fetchRow();
+		$fileSource = $row['item_source'];
+	} else {
+		$fileSource = OC_Filecache::getId($path, '');
+	}
+	
+	return $fileSource;
+}
+
 if (isset($_GET['file']) || isset($_GET['dir'])) {
 	if (isset($_GET['dir'])) {
 		$type = 'folder';
@@ -40,7 +57,7 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
 	$uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);
 	if (OCP\User::userExists($uidOwner)) {
 		OC_Util::setupFS($uidOwner);
-		$fileSource = OC_Filecache::getId($path, '');
+		$fileSource = getID($path);
 		if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) {
 			// TODO Fix in the getItems
 			if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) {

-- 
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