Skip to content

Commit 49cda5a

Browse files
marcelklehrszaimen
authored andcommitted
DAV SEARCH: Expose upload_time and creation_time
fixes #21385
1 parent 66ca9ba commit 49cda5a

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

apps/dav/lib/Connector/Sabre/FilesPlugin.php

+3
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
404404
$propFind->handle(self::CREATION_TIME_PROPERTYNAME, function () use ($node) {
405405
return $node->getFileInfo()->getCreationTime();
406406
});
407+
$propFind->handle(self::CREATIONDATE_PROPERTYNAME, function () use ($node) {
408+
return $node->getFileInfo()->getCreationTime();
409+
});
407410
}
408411

409412
if ($node instanceof \OCA\DAV\Connector\Sabre\File) {

apps/dav/lib/Files/FileSearchBackend.php

+13
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public function getPropertyDefinitionsForScope($href, $path) {
118118
new SearchPropertyDefinition('{DAV:}displayname', true, true, true),
119119
new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true),
120120
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
121+
new SearchPropertyDefinition('{DAV:}creationdate', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
122+
new SearchPropertyDefinition(FilesPlugin::CREATION_TIME_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
123+
new SearchPropertyDefinition(FilesPlugin::UPLOAD_TIME_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
121124
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
122125
new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
123126
new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, true, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
@@ -249,6 +252,11 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
249252
return $node->getName();
250253
case '{DAV:}getlastmodified':
251254
return $node->getLastModified();
255+
case '{DAV:}creationdate':
256+
case FilesPlugin::CREATION_TIME_PROPERTYNAME:
257+
return $node->getFileInfo()->getCreationTime();
258+
case FilesPlugin::UPLOAD_TIME_PROPERTYNAME:
259+
return $node->getFileInfo()->getUploadTime();
252260
case FilesPlugin::SIZE_PROPERTYNAME:
253261
return $node->getSize();
254262
case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
@@ -351,6 +359,11 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
351359
return 'mimetype';
352360
case '{DAV:}getlastmodified':
353361
return 'mtime';
362+
case '{DAV:}creationdate':
363+
case FilesPlugin::CREATION_TIME_PROPERTYNAME:
364+
return 'creation_time';
365+
case FilesPlugin::UPLOAD_TIME_PROPERTYNAME:
366+
return 'upload_time';
354367
case FilesPlugin::SIZE_PROPERTYNAME:
355368
return 'size';
356369
case TagsPlugin::FAVORITE_PROPERTYNAME:

lib/private/Files/Cache/SearchBuilder.php

+4
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ private function validateComparison(ISearchComparison $operator) {
178178
$types = [
179179
'mimetype' => 'string',
180180
'mtime' => 'integer',
181+
'creation_time' => 'integer',
182+
'upload_time' => 'integer',
181183
'name' => 'string',
182184
'path' => 'string',
183185
'size' => 'integer',
@@ -188,6 +190,8 @@ private function validateComparison(ISearchComparison $operator) {
188190
];
189191
$comparisons = [
190192
'mimetype' => ['eq', 'like'],
193+
'creation_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
194+
'upload_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
191195
'mtime' => ['eq', 'gt', 'lt', 'gte', 'lte'],
192196
'name' => ['eq', 'like', 'clike'],
193197
'path' => ['eq', 'like', 'clike'],

0 commit comments

Comments
 (0)