Skip to content

Commit 70e9e2f

Browse files
authored
Merge pull request #58566 from nextcloud/backport/58327/stable29
[stable29] feat: add upload_time support to file search and recent files
2 parents eb8c804 + 70ec5fd commit 70e9e2f

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

apps/dav/lib/Capabilities.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function getCapabilities() {
4444
$capabilities = [
4545
'dav' => [
4646
'chunking' => '1.0',
47+
'search_supports_upload_time' => true,
4748
]
4849
];
4950
if ($this->config->getSystemValueBool('bulkupload.enabled', true)) {

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public function getPropertyDefinitionsForScope(string $href, ?string $path): arr
105105
new SearchPropertyDefinition('{DAV:}displayname', true, true, true),
106106
new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true),
107107
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
108+
new SearchPropertyDefinition('{http://nextcloud.org/ns}upload_time', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
108109
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
109110
new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
110111
new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, true, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
@@ -317,6 +318,8 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
317318
return $node->getName();
318319
case '{DAV:}getlastmodified':
319320
return $node->getLastModified();
321+
case '{http://nextcloud.org/ns}upload_time':
322+
return $node->getNode()->getUploadTime();
320323
case FilesPlugin::SIZE_PROPERTYNAME:
321324
return $node->getSize();
322325
case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
@@ -471,6 +474,8 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
471474
return 'mimetype';
472475
case '{DAV:}getlastmodified':
473476
return 'mtime';
477+
case '{http://nextcloud.org/ns}upload_time':
478+
return 'upload_time';
474479
case FilesPlugin::SIZE_PROPERTYNAME:
475480
return 'size';
476481
case TagsPlugin::FAVORITE_PROPERTYNAME:

lib/private/Files/Cache/QuerySearchHelper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,12 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array
173173

174174
$builder = $this->getQueryBuilder();
175175

176-
$query = $builder->selectFileCache('file', false);
177-
178176
$requestedFields = $this->searchBuilder->extractRequestedFields($searchQuery->getSearchOperation());
179177

178+
$joinExtendedCache = in_array('upload_time', $requestedFields);
179+
180+
$query = $builder->selectFileCache('file', $joinExtendedCache);
181+
180182
if (in_array('systemtag', $requestedFields)) {
181183
$this->equipQueryForSystemTags($query, $this->requireUser($searchQuery));
182184
}

lib/private/Files/Cache/SearchBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class SearchBuilder {
8484
'share_with' => 'string',
8585
'share_type' => 'integer',
8686
'owner' => 'string',
87+
'upload_time' => 'integer',
8788
];
8889

8990
/** @var array<string, int> */
@@ -277,6 +278,7 @@ private function validateComparison(ISearchComparison $operator) {
277278
'share_with' => ['eq'],
278279
'share_type' => ['eq'],
279280
'owner' => ['eq'],
281+
'upload_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
280282
];
281283

282284
if (!isset(self::$fieldTypes[$operator->getField()])) {

0 commit comments

Comments
 (0)