Skip to content

Conversation

@tobiasKaminsky
Copy link
Member

@tobiasKaminsky tobiasKaminsky commented Aug 3, 2023

Checklist

@AndyScherzinger
Copy link
Member

/backport to stable-27.1


$propFind->handle(self::FILE_METADATA_GPS, function () use ($node) {
if (!str_starts_with($node->getFileInfo()->getMimetype(), 'image')) {
return json_encode((object)[], JSON_THROW_ON_ERROR);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just:

Suggested change
return json_encode((object)[], JSON_THROW_ON_ERROR);
return '{}';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is a one-to-one replication of the code for files-metadata-size, so I would keep it as-is.

Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndyScherzinger AndyScherzinger added the pending documentation This pull request needs an associated documentation update label Aug 7, 2023
@AndyScherzinger
Copy link
Member

Do not forget to add the prop to the documentation here:

@tobiasKaminsky I created the documentation PR, while it is lacking the examples, maybe you can add them? nextcloud/documentation#10957

@icewind1991
Copy link
Member

please also adjust the bulk-loading logic from

$metadataManager = \OC::$server->get(IMetadataManager::class);
$preloadedMetadata = $metadataManager->fetchMetadataFor('size', $fileIds);
foreach ($node->getChildren() as $child) {
/** @var \OCP\Files\Node|Node $child */
if (str_starts_with($child->getFileInfo()->getMimeType(), 'image')) {
/** @var File $child */
$child->setMetadata('size', $preloadedMetadata[$child->getFileInfo()->getId()]);
}
}
}
to ensure this doesn't because a significant performance issue

Signed-off-by: Robin Appelman <[email protected]>
@icewind1991
Copy link
Member

Added the pre-loading and de-duplicated some logic

$childrenForMeta = array_filter($children, function (INode $child) use ($relevantMimeType) {
return $child instanceof File && $child->getFileInfo()->getMimePart() === $relevantMimeType;
});
$fileIds = array_map(function (File $child) {

Check notice

Code scanning / Psalm

MissingClosureReturnType

Closure does not have a return type, expecting mixed
@icewind1991 icewind1991 merged commit bbd0deb into master Aug 8, 2023
@icewind1991 icewind1991 deleted the gps branch August 8, 2023 12:36
@backportbot-nextcloud
Copy link

The backport to stable-27.1 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable-27.1
git pull origin stable-27.1

# Create the new backport branch
git checkout -b fix/foo-stable-27.1

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable-27.1

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@icewind1991
Copy link
Member

/backport to stable27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement feature: dav pending documentation This pull request needs an associated documentation update

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants