Skip to content

Commit

Permalink
Fix an issue with the search backend update
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan committed Apr 13, 2022
1 parent 7817845 commit 09bf9cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
if ($this->config->getSystemValueBool('enable_file_metadata', true)) {
$propFind->handle(self::FILE_METADATA_SIZE, function () use ($node) {
if (!str_starts_with($node->getFileInfo()->getMimetype(), 'image')) {
return json_encode([]);
return json_encode((object)[]);
}

if ($node->hasMetadata('size')) {
Expand All @@ -460,7 +460,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
\OC::$server->get(LoggerInterface::class)->warning('Inefficient fetching of metadata');
}

return json_encode($sizeMetadata->getMetadata());
return json_encode((object)$sizeMetadata->getMetadata());
});
}
}
Expand Down
20 changes: 10 additions & 10 deletions apps/dav/lib/Files/FileSearchBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ public function getPropertyDefinitionsForScope(string $href, ?string $path): arr
new SearchPropertyDefinition(FilesPlugin::OWNER_ID_PROPERTYNAME, true, true, false),

// select only properties
new SearchPropertyDefinition('{DAV:}resourcetype', false, true, false),
new SearchPropertyDefinition('{DAV:}getcontentlength', false, true, false),
new SearchPropertyDefinition(FilesPlugin::CHECKSUMS_PROPERTYNAME, false, true, false),
new SearchPropertyDefinition(FilesPlugin::PERMISSIONS_PROPERTYNAME, false, true, false),
new SearchPropertyDefinition(FilesPlugin::GETETAG_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::HAS_PREVIEW_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_BOOLEAN),
new SearchPropertyDefinition(FilesPlugin::FILE_METADATA_SIZE, false, true, false, SearchPropertyDefinition::DATATYPE_STRING),
new SearchPropertyDefinition(FilesPlugin::FILEID_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
new SearchPropertyDefinition('{DAV:}resourcetype', true, false, false),
new SearchPropertyDefinition('{DAV:}getcontentlength', true, false, false),
new SearchPropertyDefinition(FilesPlugin::CHECKSUMS_PROPERTYNAME, true, false, false),
new SearchPropertyDefinition(FilesPlugin::PERMISSIONS_PROPERTYNAME, true, false, false),
new SearchPropertyDefinition(FilesPlugin::GETETAG_PROPERTYNAME, true, false, false),
new SearchPropertyDefinition(FilesPlugin::OWNER_DISPLAY_NAME_PROPERTYNAME, true, false, false),
new SearchPropertyDefinition(FilesPlugin::DATA_FINGERPRINT_PROPERTYNAME, true, false, false),
new SearchPropertyDefinition(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, true, false, false, SearchPropertyDefinition::DATATYPE_BOOLEAN),
new SearchPropertyDefinition(FilesPlugin::FILE_METADATA_SIZE, true, false, false, SearchPropertyDefinition::DATATYPE_STRING),
new SearchPropertyDefinition(FilesPlugin::FILEID_PROPERTYNAME, true, false, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
];
}

Expand Down
8 changes: 8 additions & 0 deletions lib/private/Metadata/Provider/ExifProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public function execute(File $file): array {
$size->setMetadata([]);

if (!$data) {
$sizeResult = getimagesizefromstring($file->getContent());
if ($sizeResult !== false) {
$size->setMetadata([
'width' => $sizeResult[0],
'height' => $sizeResult[1],
]);
}

return [
'size' => $size,
];
Expand Down

0 comments on commit 09bf9cf

Please sign in to comment.