Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/dav/lib/Files/FileSearchBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function getPropertyDefinitionsForScope(string $href, ?string $path): arr
new SearchPropertyDefinition('{DAV:}displayname', true, true, true),
new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true),
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
new SearchPropertyDefinition('{http://nextcloud.org/ns}upload_time', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, true, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
Expand Down Expand Up @@ -298,6 +299,8 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
return $node->getName();
case '{DAV:}getlastmodified':
return $node->getLastModified();
case '{http://nextcloud.org/ns}upload_time':
return $node->getNode()->getUploadTime();
case FilesPlugin::SIZE_PROPERTYNAME:
return $node->getSize();
case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
Expand Down Expand Up @@ -458,6 +461,8 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
return 'mimetype';
case '{DAV:}getlastmodified':
return 'mtime';
case '{http://nextcloud.org/ns}upload_time':
return 'upload_time';
case FilesPlugin::SIZE_PROPERTYNAME:
return 'size';
case TagsPlugin::FAVORITE_PROPERTYNAME:
Expand Down
6 changes: 4 additions & 2 deletions lib/private/Files/Cache/QuerySearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array

$builder = $this->getQueryBuilder();

$query = $builder->selectFileCache('file', false);

$requestedFields = $this->searchBuilder->extractRequestedFields($searchQuery->getSearchOperation());

$joinExtendedCache = in_array('upload_time', $requestedFields);

$query = $builder->selectFileCache('file', $joinExtendedCache);

if (in_array('systemtag', $requestedFields)) {
$this->equipQueryForSystemTags($query, $this->requireUser($searchQuery));
}
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Files/Cache/SearchBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SearchBuilder {
'share_with' => 'string',
'share_type' => 'integer',
'owner' => 'string',
'upload_time' => 'integer',
];

/** @var array<string, int|string> */
Expand Down Expand Up @@ -257,6 +258,7 @@ private function validateComparison(ISearchComparison $operator) {
'share_with' => ['eq'],
'share_type' => ['eq'],
'owner' => ['eq'],
'upload_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
];

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