From 2c8a3c0c8b8e7b4c606cb7ae07b4b6aa77ff45f1 Mon Sep 17 00:00:00 2001 From: Cristian Scheid Date: Fri, 13 Feb 2026 14:37:28 -0300 Subject: [PATCH 1/2] feat: add upload_time support to file search and recent files Signed-off-by: Cristian Scheid --- apps/dav/lib/Files/FileSearchBackend.php | 5 +++++ lib/private/Files/Cache/QuerySearchHelper.php | 6 ++++-- lib/private/Files/Cache/SearchBuilder.php | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php index d5492a42ffca8..63695de6185ed 100644 --- a/apps/dav/lib/Files/FileSearchBackend.php +++ b/apps/dav/lib/Files/FileSearchBackend.php @@ -105,6 +105,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), @@ -317,6 +318,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: @@ -471,6 +474,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: diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index 849135d44f00e..4f8aa3e8cce23 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -173,10 +173,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)); } diff --git a/lib/private/Files/Cache/SearchBuilder.php b/lib/private/Files/Cache/SearchBuilder.php index 1ba1aa5be9631..0fd64a62ec388 100644 --- a/lib/private/Files/Cache/SearchBuilder.php +++ b/lib/private/Files/Cache/SearchBuilder.php @@ -84,6 +84,7 @@ class SearchBuilder { 'share_with' => 'string', 'share_type' => 'integer', 'owner' => 'string', + 'upload_time' => 'integer', ]; /** @var array */ @@ -277,6 +278,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()])) { From 70ec5fdc43a663c8a458dfc692db9924a31df223 Mon Sep 17 00:00:00 2001 From: Cristian Scheid Date: Wed, 25 Feb 2026 13:16:43 -0300 Subject: [PATCH 2/2] feat(dav): expose search_supports_upload_time capability Signed-off-by: Cristian Scheid --- apps/dav/lib/Capabilities.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dav/lib/Capabilities.php b/apps/dav/lib/Capabilities.php index 9566b029a99a8..a019f4dfaee9b 100644 --- a/apps/dav/lib/Capabilities.php +++ b/apps/dav/lib/Capabilities.php @@ -44,6 +44,7 @@ public function getCapabilities() { $capabilities = [ 'dav' => [ 'chunking' => '1.0', + 'search_supports_upload_time' => true, ] ]; if ($this->config->getSystemValueBool('bulkupload.enabled', true)) {