Skip to content

Commit

Permalink
DAV SEARCH: Expose upload_time and creation_time
Browse files Browse the repository at this point in the history
fixes #21385
  • Loading branch information
marcelklehr committed Dec 21, 2021
1 parent 1acfbd0 commit ba11d93
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class FilesPlugin extends ServerPlugin {
public const SIZE_PROPERTYNAME = '{http://owncloud.org/ns}size';
public const GETETAG_PROPERTYNAME = '{DAV:}getetag';
public const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
public const CREATIONDATE_PROPERTYNAME = '{DAV:}creationdate';
public const OWNER_ID_PROPERTYNAME = '{http://owncloud.org/ns}owner-id';
public const OWNER_DISPLAY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}owner-display-name';
public const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
Expand Down Expand Up @@ -398,6 +399,9 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
$propFind->handle(self::CREATION_TIME_PROPERTYNAME, function () use ($node) {
return $node->getFileInfo()->getCreationTime();
});
$propFind->handle(self::CREATIONDATE_PROPERTYNAME, function () use ($node) {
return $node->getFileInfo()->getCreationTime();
});
}

if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
Expand Down
13 changes: 13 additions & 0 deletions apps/dav/lib/Files/FileSearchBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public function getPropertyDefinitionsForScope($href, $path) {
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('{DAV:}creationdate', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
new SearchPropertyDefinition(FilesPlugin::CREATION_TIME_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
new SearchPropertyDefinition(FilesPlugin::UPLOAD_TIME_PROPERTYNAME, 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 @@ -249,6 +252,11 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
return $node->getName();
case '{DAV:}getlastmodified':
return $node->getLastModified();
case '{DAV:}creationdate':
case FilesPlugin::CREATION_TIME_PROPERTYNAME:
return $node->getFileInfo()->getCreationTime();
case FilesPlugin::UPLOAD_TIME_PROPERTYNAME:
return $node->getFileInfo()->getUploadTime();
case FilesPlugin::SIZE_PROPERTYNAME:
return $node->getSize();
case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
Expand Down Expand Up @@ -351,6 +359,11 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
return 'mimetype';
case '{DAV:}getlastmodified':
return 'mtime';
case '{DAV:}creationdate':
case FilesPlugin::CREATION_TIME_PROPERTYNAME:
return 'creation_time';
case FilesPlugin::UPLOAD_TIME_PROPERTYNAME:
return 'upload_time';
case FilesPlugin::SIZE_PROPERTYNAME:
return 'size';
case TagsPlugin::FAVORITE_PROPERTYNAME:
Expand Down
4 changes: 4 additions & 0 deletions lib/private/Files/Cache/SearchBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ private function validateComparison(ISearchComparison $operator) {
$types = [
'mimetype' => 'string',
'mtime' => 'integer',
'creation_time' => 'integer',
'upload_time' => 'integer',
'name' => 'string',
'path' => 'string',
'size' => 'integer',
Expand All @@ -188,6 +190,8 @@ private function validateComparison(ISearchComparison $operator) {
];
$comparisons = [
'mimetype' => ['eq', 'like'],
'creation_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
'upload_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
'mtime' => ['eq', 'gt', 'lt', 'gte', 'lte'],
'name' => ['eq', 'like', 'clike'],
'path' => ['eq', 'like', 'clike'],
Expand Down

0 comments on commit ba11d93

Please sign in to comment.