aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2024-07-30 08:59:46 +0200
committerRichard Steinmetz <richard@steinmetz.cloud>2024-07-30 09:09:26 +0200
commit08c785ff4665351ff30f72c92cc06f5b9735dce8 (patch)
treede12dad2503c1eade2cfde315c9e1bdd4bfa044c /lib
parentc882d78f58754e3bbb61e98be0a73e5ba4807ab4 (diff)
downloadnextcloud-server-08c785ff4665351ff30f72c92cc06f5b9735dce8.tar.gz
nextcloud-server-08c785ff4665351ff30f72c92cc06f5b9735dce8.zip
fix: don't persist previews used during blurhash generation
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php23
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php b/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php
index 61ace449453..bb5bc3cadb2 100644
--- a/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php
+++ b/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php
@@ -15,12 +15,10 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\GenericFileException;
-use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\FilesMetadata\AMetadataEvent;
use OCP\FilesMetadata\Event\MetadataBackgroundEvent;
use OCP\FilesMetadata\Event\MetadataLiveEvent;
-use OCP\IPreview;
use OCP\Lock\LockedException;
/**
@@ -34,11 +32,6 @@ class GenerateBlurhashMetadata implements IEventListener {
private const COMPONENTS_X = 4;
private const COMPONENTS_Y = 3;
- public function __construct(
- private IPreview $preview,
- ) {
- }
-
/**
* @throws NotPermittedException
* @throws GenericFileException
@@ -67,20 +60,12 @@ class GenerateBlurhashMetadata implements IEventListener {
return;
}
- $image = false;
- try {
- // using preview image to generate the blurhash
- $preview = $this->preview->getPreview($file, 256, 256);
- $image = @imagecreatefromstring($preview->getContent());
- } catch (NotFoundException $e) {
- // https://github.com/nextcloud/server/blob/9d70fd3e64b60a316a03fb2b237891380c310c58/lib/private/legacy/OC_Image.php#L668
- // The preview system can fail on huge picture, in that case we use our own image resizer.
- if (str_starts_with($file->getMimetype(), 'image/')) {
- $image = $this->resizedImageFromFile($file);
- }
+ if (!str_starts_with($file->getMimetype(), 'image/')) {
+ return;
}
- if ($image === false) {
+ $image = $this->resizedImageFromFile($file);
+ if (!$image) {
return;
}