From c53c4b9791914a7449adc1d73b2e66189100328b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 25 Apr 2014 12:28:10 +0200 Subject: [PATCH 1/3] fix search by mime for shared single files --- apps/files_sharing/lib/cache.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 67a0410ef7..fa86d55730 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -86,14 +86,13 @@ class Shared_Cache extends Cache { public function get($file) { if (is_string($file)) { if ($cache = $this->getSourceCache($file)) { - $path = 'files' . $this->storage->getMountPoint(); - $path .= ($file !== '') ? '/' . $file : ''; $data = $cache->get($this->files[$file]); $data['displayname_owner'] = \OC_User::getDisplayName($this->storage->getSharedFrom()); - $data['path'] = $path; + $data['path'] = ''; if ($file === '') { $data['is_share_mount_point'] = true; } + $data['uid_owner'] = $this->storage->getOwner($file); return $data; } } else { @@ -299,6 +298,11 @@ class Shared_Cache extends Cache { $files = $this->getFolderContents($dir); // no results? if (!$files) { + // maybe it's a single shared file + $file = $this->get(''); + if (($mimepart && $file['mimepart'] === $mimepart) || ($mimetype && $file['mimetype'] === $mimetype)) { + $result[] = $file; + } continue; } foreach ($files as $file) { From 672a8248ce185cb38a6b8ae9617eb0e6bb186f8b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 25 Apr 2014 13:56:45 +0200 Subject: [PATCH 2/3] Correct the path returned by getFolderContent for substorages --- lib/private/files/view.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 58dfc73dcf..5a3872e66e 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -996,6 +996,7 @@ class View { break; } } + $rootEntry['path'] = substr($path . '/' . $rootEntry['name'], strlen($user) + 2); // full path without /$user/ $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry); } } From b42418246f3c0d623fc9cd028e905ac3b1303a9f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 25 Apr 2014 14:04:22 +0200 Subject: [PATCH 3/3] Also fixed the returned internal path when getting the root shared item by id --- apps/files_sharing/lib/cache.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index fa86d55730..8c680e9c97 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -88,7 +88,7 @@ class Shared_Cache extends Cache { if ($cache = $this->getSourceCache($file)) { $data = $cache->get($this->files[$file]); $data['displayname_owner'] = \OC_User::getDisplayName($this->storage->getSharedFrom()); - $data['path'] = ''; + $data['path'] = $file; if ($file === '') { $data['is_share_mount_point'] = true; } @@ -100,7 +100,6 @@ class Shared_Cache extends Cache { // cache information for the source item if (!is_int($file) || $file === 0) { $file = $this->storage->getSourceId(); - $mountPoint = $this->storage->getMountPoint(); } $query = \OC_DB::prepare( 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`,' @@ -123,8 +122,8 @@ class Shared_Cache extends Cache { } else { $data['size'] = (int)$data['size']; } - if (isset($mountPoint)) { - $data['path'] = 'files/' . $mountPoint; + if (!is_int($file) || $file === 0) { + $data['path'] = ''; $data['is_share_mount_point'] = true; } return $data;