summaryrefslogtreecommitdiffstats
path: root/apps/files/service
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-18 15:58:06 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-03-23 15:10:58 +0100
commit1a262631235445d6ba4d9d0b5bdbc84355e43e5c (patch)
tree8589630937f6e39fe918160f0011b63cb30a041a /apps/files/service
parent093efa458c16ea4a7f7fcaf3f98e1e0fb96624c4 (diff)
downloadnextcloud-server-1a262631235445d6ba4d9d0b5bdbc84355e43e5c.tar.gz
nextcloud-server-1a262631235445d6ba4d9d0b5bdbc84355e43e5c.zip
Do not walk over the users directory, but over the list of tagged objects
Way quicker
Diffstat (limited to 'apps/files/service')
-rw-r--r--apps/files/service/tagservice.php25
1 files changed, 11 insertions, 14 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;
}
}