]> source.dussan.org Git - nextcloud-server.git/commitdiff
Shared files are not stored in the file cache. Therefore we need to
authorBjörn Schießle <schiessle@owncloud.com>
Wed, 24 Oct 2012 11:09:43 +0000 (13:09 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Wed, 24 Oct 2012 11:11:29 +0000 (13:11 +0200)
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

index 1a0f6b2cdee5769728c231767f3397b8a711e961..a8813085d09239bcc2ca42cd5cd3d77aecaf40ed 100644 (file)
@@ -21,6 +21,23 @@ if (isset($_GET['token'])) {
 }\r
 // Enf of backward compatibility\r
 \r
+function getID($path) {\r
+       // 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.\r
+       if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") {\r
+               $path_parts = explode('/', $path, 5);\r
+               $user = $path_parts[1];\r
+               $intPath = '/'.$path_parts[4];\r
+               $query = \OC_DB::prepare('SELECT item_source FROM *PREFIX*share WHERE uid_owner = ? AND file_target = ? ');\r
+               $result = $query->execute(array($user, $intPath));\r
+               $row = $result->fetchRow();\r
+               $fileSource = $row['item_source'];\r
+       } else {\r
+               $fileSource = OC_Filecache::getId($path, '');\r
+       }\r
+\r
+       return $fileSource;\r
+}\r
+\r
 if (isset($_GET['file']) || isset($_GET['dir'])) {\r
        if (isset($_GET['dir'])) {\r
                $type = 'folder';\r
@@ -40,7 +57,7 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
        $uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);\r
        if (OCP\User::userExists($uidOwner)) {\r
                OC_Util::setupFS($uidOwner);\r
-               $fileSource = OC_Filecache::getId($path, '');\r
+               $fileSource = getId($path);\r
                if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) {\r
                        // TODO Fix in the getItems\r
                        if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) {\r