Skip to content

Commit d4aae76

Browse files
authored
Merge pull request #58564 from nextcloud/backport/58327/stable31
[stable31] feat: add upload_time support to file search and recent files
2 parents c7c7e10 + ca83a5e commit d4aae76

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
@@ -23,6 +23,7 @@ public function getCapabilities() {
2323
$capabilities = [
2424
'dav' => [
2525
'chunking' => '1.0',
26+
'search_supports_upload_time' => true,
2627
]
2728
];
2829
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
@@ -85,6 +85,7 @@ public function getPropertyDefinitionsForScope(string $href, ?string $path): arr
8585
new SearchPropertyDefinition('{DAV:}displayname', true, true, true),
8686
new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true),
8787
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
88+
new SearchPropertyDefinition('{http://nextcloud.org/ns}upload_time', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
8889
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
8990
new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
9091
new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, true, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
@@ -297,6 +298,8 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
297298
return $node->getName();
298299
case '{DAV:}getlastmodified':
299300
return $node->getLastModified();
301+
case '{http://nextcloud.org/ns}upload_time':
302+
return $node->getNode()->getUploadTime();
300303
case FilesPlugin::SIZE_PROPERTYNAME:
301304
return $node->getSize();
302305
case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
@@ -451,6 +454,8 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
451454
return 'mimetype';
452455
case '{DAV:}getlastmodified':
453456
return 'mtime';
457+
case '{http://nextcloud.org/ns}upload_time':
458+
return 'upload_time';
454459
case FilesPlugin::SIZE_PROPERTYNAME:
455460
return 'size';
456461
case TagsPlugin::FAVORITE_PROPERTYNAME:

lib/private/Files/Cache/QuerySearchHelper.php

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

150150
$builder = $this->getQueryBuilder();
151151

152-
$query = $builder->selectFileCache('file', false);
153-
154152
$requestedFields = $this->searchBuilder->extractRequestedFields($searchQuery->getSearchOperation());
155153

154+
$joinExtendedCache = in_array('upload_time', $requestedFields);
155+
156+
$query = $builder->selectFileCache('file', $joinExtendedCache);
157+
156158
if (in_array('systemtag', $requestedFields)) {
157159
$this->equipQueryForSystemTags($query, $this->requireUser($searchQuery));
158160
}

lib/private/Files/Cache/SearchBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class SearchBuilder {
6363
'share_with' => 'string',
6464
'share_type' => 'integer',
6565
'owner' => 'string',
66+
'upload_time' => 'integer',
6667
];
6768

6869
/** @var array<string, int|string> */
@@ -256,6 +257,7 @@ private function validateComparison(ISearchComparison $operator) {
256257
'share_with' => ['eq'],
257258
'share_type' => ['eq'],
258259
'owner' => ['eq'],
260+
'upload_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
259261
];
260262

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

0 commit comments

Comments
 (0)