summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/utils/scanner.php4
-rw-r--r--lib/private/systemtag/systemtagobjectmapper.php25
-rw-r--r--lib/public/systemtag/isystemtagobjectmapper.php6
3 files changed, 27 insertions, 8 deletions
diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php
index 59673a306cb..bc815f5f6da 100644
--- a/lib/private/files/utils/scanner.php
+++ b/lib/private/files/utils/scanner.php
@@ -119,6 +119,10 @@ class Scanner extends PublicEmitter {
if (is_null($mount->getStorage())) {
continue;
}
+ // don't scan the root storage
+ if ($mount->getStorage()->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') {
+ continue;
+ }
$scanner = $mount->getStorage()->getScanner();
$this->attachListener($mount);
$scanner->backgroundScan();
diff --git a/lib/private/systemtag/systemtagobjectmapper.php b/lib/private/systemtag/systemtagobjectmapper.php
index 1efb4f0f6e0..586351cf8c1 100644
--- a/lib/private/systemtag/systemtagobjectmapper.php
+++ b/lib/private/systemtag/systemtagobjectmapper.php
@@ -95,7 +95,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
/**
* {@inheritdoc}
*/
- public function getObjectIdsForTags($tagIds, $objectType) {
+ public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = '') {
if (!is_array($tagIds)) {
$tagIds = [$tagIds];
}
@@ -103,12 +103,23 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
$this->assertTagsExist($tagIds);
$query = $this->connection->getQueryBuilder();
- $query->select($query->createFunction('DISTINCT(`objectid`)'))
+ $query->selectDistinct('objectid')
->from(self::RELATION_TABLE)
- ->where($query->expr()->in('systemtagid', $query->createParameter('tagids')))
- ->andWhere($query->expr()->eq('objecttype', $query->createParameter('objecttype')))
- ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY)
- ->setParameter('objecttype', $objectType);
+ ->where($query->expr()->in('systemtagid', $query->createNamedParameter($tagIds, IQueryBuilder::PARAM_INT_ARRAY)))
+ ->andWhere($query->expr()->eq('objecttype', $query->createNamedParameter($objectType)));
+
+ if ($limit) {
+ if (sizeof($tagIds) !== 1) {
+ throw new \InvalidArgumentException('Limit is only allowed with a single tag');
+ }
+
+ $query->setMaxResults($limit)
+ ->orderBy('objectid', 'ASC');
+
+ if ($offset !== '') {
+ $query->andWhere($query->expr()->gt('objectid', $query->createNamedParameter($offset)));
+ }
+ }
$objectIds = [];
@@ -208,7 +219,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
->where($query->expr()->in('objectid', $query->createParameter('objectids')))
->andWhere($query->expr()->eq('objecttype', $query->createParameter('objecttype')))
->andWhere($query->expr()->eq('systemtagid', $query->createParameter('tagid')))
- ->setParameter('objectids', $objIds, IQueryBuilder::PARAM_INT_ARRAY)
+ ->setParameter('objectids', $objIds, IQueryBuilder::PARAM_STR_ARRAY)
->setParameter('tagid', $tagId)
->setParameter('objecttype', $objectType);
diff --git a/lib/public/systemtag/isystemtagobjectmapper.php b/lib/public/systemtag/isystemtagobjectmapper.php
index 8db5cdd31aa..59b988a3656 100644
--- a/lib/public/systemtag/isystemtagobjectmapper.php
+++ b/lib/public/systemtag/isystemtagobjectmapper.php
@@ -57,15 +57,19 @@ interface ISystemTagObjectMapper {
*
* @param string|array $tagIds Tag id or array of tag ids.
* @param string $objectType object type
+ * @param int $limit Count of object ids you want to get
+ * @param string $offset The last object id you already received
*
* @return string[] array of object ids or empty array if none found
*
* @throws \OCP\SystemTag\TagNotFoundException if at least one of the
* given tags does not exist
+ * @throws \InvalidArgumentException When a limit is specified together with
+ * multiple tag ids
*
* @since 9.0.0
*/
- public function getObjectIdsForTags($tagIds, $objectType);
+ public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = '');
/**
* Assign the given tags to the given object.