Browse Source

Merge pull request #4222 from nextcloud/dav-search-fileid

Allow searching file by fileid
pull/4282/head
Roeland Jago Douma 9 years ago
committed by GitHub
parent
commit
e9c6fe2fd8
  1. 4
      apps/dav/lib/Files/FileSearchBackend.php
  2. 4
      lib/private/Files/Cache/QuerySearchHelper.php

4
apps/dav/lib/Files/FileSearchBackend.php

@ -116,6 +116,7 @@ class FileSearchBackend implements ISearchBackend {
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME), new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER), 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(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, true, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
// select only properties // select only properties
new SearchPropertyDefinition('{DAV:}resourcetype', false, true, false), new SearchPropertyDefinition('{DAV:}resourcetype', false, true, false),
@ -127,7 +128,6 @@ class FileSearchBackend implements ISearchBackend {
new SearchPropertyDefinition(FilesPlugin::OWNER_DISPLAY_NAME_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::OWNER_DISPLAY_NAME_PROPERTYNAME, false, true, false),
new SearchPropertyDefinition(FilesPlugin::DATA_FINGERPRINT_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::DATA_FINGERPRINT_PROPERTYNAME, false, true, false),
new SearchPropertyDefinition(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_BOOLEAN), new SearchPropertyDefinition(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_BOOLEAN),
new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
new SearchPropertyDefinition(FilesPlugin::FILEID_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER), new SearchPropertyDefinition(FilesPlugin::FILEID_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
]; ];
} }
@ -244,6 +244,8 @@ class FileSearchBackend implements ISearchBackend {
return 'favorite'; return 'favorite';
case TagsPlugin::TAGS_PROPERTYNAME: case TagsPlugin::TAGS_PROPERTYNAME:
return 'tagname'; return 'tagname';
case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
return 'fileid';
default: default:
throw new \InvalidArgumentException('Unsupported property for search or order: ' . $propertyName); throw new \InvalidArgumentException('Unsupported property for search or order: ' . $propertyName);
} }

4
lib/private/Files/Cache/QuerySearchHelper.php

@ -152,7 +152,8 @@ class QuerySearchHelper {
'name' => 'string', 'name' => 'string',
'size' => 'integer', 'size' => 'integer',
'tagname' => 'string', 'tagname' => 'string',
'favorite' => 'boolean'
'favorite' => 'boolean',
'fileid' => 'integer'
]; ];
$comparisons = [ $comparisons = [
'mimetype' => ['eq', 'like'], 'mimetype' => ['eq', 'like'],
@ -161,6 +162,7 @@ class QuerySearchHelper {
'size' => ['eq', 'gt', 'lt', 'gte', 'lte'], 'size' => ['eq', 'gt', 'lt', 'gte', 'lte'],
'tagname' => ['eq', 'like'], 'tagname' => ['eq', 'like'],
'favorite' => ['eq'], 'favorite' => ['eq'],
'fileid' => ['eq']
]; ];
if (!isset($types[$operator->getField()])) { if (!isset($types[$operator->getField()])) {

Loading…
Cancel
Save