summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-01-19 15:30:27 +0100
committerRobin Appelman <robin@icewind.nl>2021-01-26 15:30:50 +0100
commit27f9df2e87e39a79e07b4edcbe63315403a7bed1 (patch)
treea3b412ccbb4233bd59114ba2559bcdd3612ab814 /lib
parenta44aab11f726dfe9bacb38339e2da59cdeb8f467 (diff)
downloadnextcloud-server-27f9df2e87e39a79e07b4edcbe63315403a7bed1.tar.gz
nextcloud-server-27f9df2e87e39a79e07b4edcbe63315403a7bed1.zip
fix cachjail searching for root
Signed-off-by: Robin Appelman <robin@icewind.nl>
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);