]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow searching file by fileid 4222/head
authorRobin Appelman <robin@icewind.nl>
Wed, 5 Apr 2017 13:12:30 +0000 (15:12 +0200)
committerRobin Appelman <robin@icewind.nl>
Wed, 5 Apr 2017 13:22:53 +0000 (15:22 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/dav/lib/Files/FileSearchBackend.php
lib/private/Files/Cache/QuerySearchHelper.php

index 5816c6599321373d26659114f90016f38a2390cd..0d837807fd8f9726d65bbf84a5fffa7d295d78dc 100644 (file)
@@ -116,6 +116,7 @@ class FileSearchBackend implements ISearchBackend {
                        new SearchPropertyDefinition('{DAV:}getlastmodified', 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),
 
                        // select only properties
                        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::DATA_FINGERPRINT_PROPERTYNAME, false, true, false),
                        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),
                ];
        }
@@ -222,7 +222,7 @@ class FileSearchBackend implements ISearchBackend {
                        case Operator::OPERATION_IS_COLLECTION:
                                return new SearchComparison('eq', 'mimetype', ICacheEntry::DIRECTORY_MIMETYPE);
                        default:
-                               throw new \InvalidArgumentException('Unsupported operation ' . $trimmedType ' (' . $operator->type . ')');
+                               throw new \InvalidArgumentException('Unsupported operation ' . $trimmedType . ' (' . $operator->type . ')');
                }
        }
 
@@ -244,6 +244,8 @@ class FileSearchBackend implements ISearchBackend {
                                return 'favorite';
                        case TagsPlugin::TAGS_PROPERTYNAME:
                                return 'tagname';
+                       case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
+                               return 'fileid';
                        default:
                                throw new \InvalidArgumentException('Unsupported property for search or order: ' . $propertyName);
                }
@@ -266,7 +268,7 @@ class FileSearchBackend implements ISearchBackend {
                                                        return 0 + $value;
                                                }
                                                $date = \DateTime::createFromFormat(\DateTime::ATOM, $value);
-                                               return ($date instanceof  \DateTime) ? $date->getTimestamp() : 0;
+                                               return ($date instanceof \DateTime) ? $date->getTimestamp() : 0;
                                        default:
                                                return $value;
                                }
index 2d20da72f51a02e71593c8ed00d4d400b40428e9..6812caabd2430ff5e98b4fd0251bdf0f434c710d 100644 (file)
@@ -152,7 +152,8 @@ class QuerySearchHelper {
                        'name' => 'string',
                        'size' => 'integer',
                        'tagname' => 'string',
-                       'favorite' => 'boolean'
+                       'favorite' => 'boolean',
+                       'fileid' => 'integer'
                ];
                $comparisons = [
                        'mimetype' => ['eq', 'like'],
@@ -161,6 +162,7 @@ class QuerySearchHelper {
                        'size' => ['eq', 'gt', 'lt', 'gte', 'lte'],
                        'tagname' => ['eq', 'like'],
                        'favorite' => ['eq'],
+                       'fileid' => ['eq']
                ];
 
                if (!isset($types[$operator->getField()])) {