summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-03-24 13:26:59 +0100
committerVincent Petry <pvince81@owncloud.com>2015-03-24 13:26:59 +0100
commit46475bf580f4895899a4b924a8970e91163e3c63 (patch)
tree9ed24f4f5202cc2ffb38c72be30aa154f83586c8
parentc8af615c01c4fb9d0de2abd100bf0600d5403c88 (diff)
parent1a262631235445d6ba4d9d0b5bdbc84355e43e5c (diff)
downloadnextcloud-server-46475bf580f4895899a4b924a8970e91163e3c63.tar.gz
nextcloud-server-46475bf580f4895899a4b924a8970e91163e3c63.zip
Merge pull request #15003 from owncloud/issue/14859-speed-up-favorite-list
Do not walk over the users directory, but over the list of tagged objects
-rw-r--r--apps/files/service/tagservice.php25
-rw-r--r--lib/private/tags.php5
2 files changed, 14 insertions, 16 deletions
diff --git a/apps/files/service/tagservice.php b/apps/files/service/tagservice.php
index fe26838552a..cdd51d27f4a 100644
--- a/apps/files/service/tagservice.php
+++ b/apps/files/service/tagservice.php
@@ -48,7 +48,7 @@ class TagService {
* @param string $path path
* @param array $tags array of tags
* @return array list of tags
- * @throws \OCP\NotFoundException if the file does not exist
+ * @throws \OCP\Files\NotFoundException if the file does not exist
*/
public function updateFileTags($path, $tags) {
$fileId = $this->homeFolder->get($path)->getId();
@@ -74,30 +74,27 @@ class TagService {
}
/**
- * Updates the tags of the specified file path.
- * The passed tags are absolute, which means they will
- * replace the actual tag selection.
+ * Get all files for the given tag
*
* @param array $tagName tag name to filter by
* @return FileInfo[] list of matching files
* @throws \Exception if the tag does not exist
*/
public function getFilesByTag($tagName) {
- $nodes = $this->homeFolder->searchByTag(
- $tagName, $this->userSession->getUser()->getUId()
- );
+ try {
+ $fileIds = $this->tagger->getIdsForTag($tagName);
+ } catch (\Exception $e) {
+ return [];
+ }
+
$fileInfos = [];
- foreach ($nodes as $node) {
- try {
+ foreach ($fileIds as $fileId) {
+ $nodes = $this->homeFolder->getById((int) $fileId);
+ foreach ($nodes as $node) {
/** @var \OC\Files\Node\Node $node */
$fileInfos[] = $node->getFileInfo();
- } catch (\Exception $e) {
- // FIXME Should notify the user, when this happens
- // Can not get FileInfo, maybe the connection to the external
- // storage is interrupted.
}
}
-
return $fileInfos;
}
}
diff --git a/lib/private/tags.php b/lib/private/tags.php
index 200ec8c2771..276da9d4b80 100644
--- a/lib/private/tags.php
+++ b/lib/private/tags.php
@@ -34,8 +34,8 @@
namespace OC;
-use \OC\Tagging\Tag,
- \OC\Tagging\TagMapper;
+use \OC\Tagging\Tag;
+use \OC\Tagging\TagMapper;
class Tags implements \OCP\ITags {
@@ -248,6 +248,7 @@ class Tags implements \OCP\ITags {
*
* @param string $tag Tag id or name.
* @return array|false An array of object ids or false on error.
+ * @throws \Exception
*/
public function getIdsForTag($tag) {
$result = null;