aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-02-09 09:54:52 +0100
committerRobin Appelman <robin@icewind.nl>2024-03-04 13:57:31 +0100
commite7a7b4a40184dc3da2c83e858c820625f660e48e (patch)
tree367bda0ac814376e7c771fbe4b1c40cf7f33df53 /core/Command
parent4d110c1dd6ae384c00c93b4e266118004b71e498 (diff)
downloadnextcloud-server-e7a7b4a40184dc3da2c83e858c820625f660e48e.tar.gz
nextcloud-server-e7a7b4a40184dc3da2c83e858c820625f660e48e.zip
perf: switch places that always use the first getById result to getFirstNodeById
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/FilesMetadata/Get.php6
-rw-r--r--core/Command/Info/FileUtils.php6
-rw-r--r--core/Command/Preview/Generate.php6
3 files changed, 5 insertions, 13 deletions
diff --git a/core/Command/FilesMetadata/Get.php b/core/Command/FilesMetadata/Get.php
index 99bc167f71d..d1def992c8a 100644
--- a/core/Command/FilesMetadata/Get.php
+++ b/core/Command/FilesMetadata/Get.php
@@ -96,12 +96,12 @@ class Get extends Command {
}
if ($input->getOption('refresh')) {
- $node = $this->rootFolder->getUserFolder($input->getArgument('userId'))->getById($fileId);
- if (count($node) === 0) {
+ $node = $this->rootFolder->getUserFolder($input->getArgument('userId'))->getFirstNodeById($fileId);
+ if (!$node) {
throw new NotFoundException();
}
$metadata = $this->filesMetadataManager->refreshMetadata(
- $node[0],
+ $node,
IFilesMetadataManager::PROCESS_LIVE | IFilesMetadataManager::PROCESS_BACKGROUND
);
} else {
diff --git a/core/Command/Info/FileUtils.php b/core/Command/Info/FileUtils.php
index 694f30f78b4..595a0216a5c 100644
--- a/core/Command/Info/FileUtils.php
+++ b/core/Command/Info/FileUtils.php
@@ -87,11 +87,7 @@ class FileUtils {
}
$mount = $mounts[0];
$userFolder = $this->rootFolder->getUserFolder($mount->getUser()->getUID());
- $nodes = $userFolder->getById((int)$fileInput);
- if (!$nodes) {
- return null;
- }
- return $nodes[0];
+ return $userFolder->getFirstNodeById((int)$fileInput);
} else {
try {
return $this->rootFolder->get($fileInput);
diff --git a/core/Command/Preview/Generate.php b/core/Command/Preview/Generate.php
index a885d224fc7..86528319199 100644
--- a/core/Command/Preview/Generate.php
+++ b/core/Command/Preview/Generate.php
@@ -121,11 +121,7 @@ class Generate extends Command {
}
$mount = $mounts[0];
$userFolder = $this->rootFolder->getUserFolder($mount->getUser()->getUID());
- $nodes = $userFolder->getById((int)$fileInput);
- if (!$nodes) {
- return null;
- }
- return $nodes[0];
+ return $userFolder->getFirstNodeById((int)$fileInput);
} else {
try {
return $this->rootFolder->get($fileInput);