summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php3
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheJail.php17
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index 5e33ad235a0..16b15aa6b3b 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -166,6 +166,9 @@ class QuerySearchHelper {
$field = 'tag.category';
} elseif ($field === 'fileid') {
$field = 'file.fileid';
+ } elseif ($field === 'path' && $type === ISearchComparison::COMPARE_EQUAL) {
+ $field = 'path_hash';
+ $value = md5((string)$value);
}
return [$field, $value, $type];
}
diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php
index 27590fb7418..2f873a65cfe 100644
--- a/lib/private/Files/Cache/Wrapper/CacheJail.php
+++ b/lib/private/Files/Cache/Wrapper/CacheJail.php
@@ -238,7 +238,10 @@ class CacheJail extends CacheWrapper {
$query = $this->getQueryBuilder();
$query->selectFileCache()
->whereStorageId()
- ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->getRoot() . '/%')))
+ ->andWhere($query->expr()->orX(
+ $query->expr()->like('path', $query->createNamedParameter($this->getRoot() . '/%')),
+ $query->expr()->eq('path_hash', $query->createNamedParameter(md5($this->getRoot()))),
+ ))
->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern)));
$result = $query->execute();
@@ -263,7 +266,10 @@ class CacheJail extends CacheWrapper {
$query = $this->getQueryBuilder();
$query->selectFileCache()
->whereStorageId()
- ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->getRoot() . '/%')));
+ ->andWhere($query->expr()->orX(
+ $query->expr()->like('path', $query->createNamedParameter($this->getRoot() . '/%')),
+ $query->expr()->eq('path_hash', $query->createNamedParameter(md5($this->getRoot()))),
+ ));
if (strpos($mimetype, '/')) {
$query->andWhere($query->expr()->eq('mimetype', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT)));
@@ -287,9 +293,14 @@ class CacheJail extends CacheWrapper {
'path',
$this->getRoot() . '/%'
);
+ $rootFilter = new SearchComparison(
+ ISearchComparison::COMPARE_EQUAL,
+ 'path',
+ $this->getRoot()
+ );
$operation = new SearchBinaryOperator(
ISearchBinaryOperator::OPERATOR_AND,
- [$prefixFilter, $query->getSearchOperation()]
+ [new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [$prefixFilter, $rootFilter]) , $query->getSearchOperation()]
);
$simpleQuery = new SearchQuery($operation, 0, 0, $query->getOrder(), $query->getUser());
$results = $this->getCache()->searchQuery($simpleQuery);