From 274484ebc68fec0548827b4220d17c947bb4fcf8 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Wed, 29 Jan 2025 10:44:46 +0100 Subject: [PATCH] fix: Read from local file stream to avoid locking during preview generation Signed-off-by: Julius Knorr --- lib/Service/RemoteService.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/Service/RemoteService.php b/lib/Service/RemoteService.php index 2b1d2490d7..239ee7ed4a 100644 --- a/lib/Service/RemoteService.php +++ b/lib/Service/RemoteService.php @@ -52,16 +52,11 @@ public function fetchTargetThumbnail(File $file, string $target): ?string { } private function getRequestOptionsForFile(File $file, ?string $target = null): array { - $useTempFile = $file->isEncrypted() || !$file->getStorage()->isLocal(); - if ($useTempFile) { - $localFile = $file->getStorage()->getLocalFile($file->getInternalPath()); - if (!is_string($localFile)) { - throw new NotFoundException('Could not get local file'); - } - $stream = fopen($localFile, 'rb'); - } else { - $stream = $file->fopen('rb'); + $localFile = $file->getStorage()->getLocalFile($file->getInternalPath()); + if (!is_string($localFile)) { + throw new NotFoundException('Could not get local file'); } + $stream = fopen($localFile, 'rb'); $options = RemoteOptionsService::getDefaultOptions(25); $options['multipart'] = [