]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix crop condition 32513/head
authorCarl Schwan <carl@carlschwan.eu>
Thu, 19 May 2022 11:13:41 +0000 (13:13 +0200)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Fri, 20 May 2022 11:03:15 +0000 (11:03 +0000)
Make sure that when fetching the image from the cache we don't
accidentally fetch the cropped image just because it also start with
256-256

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
lib/private/Preview/Generator.php

index e058a15bfa5536a6a7891f41850e34e7b2527a4b..f9985bc299d54c9608b273589a6c76dc547fadec 100644 (file)
@@ -232,9 +232,17 @@ class Generator {
 
                foreach ($nodes as $node) {
                        $name = $node->getName();
-                       if (($prefix === '' || strpos($name, $prefix) === 0)
-                               && (str_starts_with($name, '256-256-crop') && $crop || str_starts_with($name, '256-256') && !$crop)) {
-                               return $node;
+                       if (($prefix === '' || str_starts_with($name, $prefix))) {
+                               // Prefix match
+                               if (str_starts_with($name, $prefix . '256-256-crop') && $crop) {
+                                       // Cropped image
+                                       return $node;
+                               }
+
+                               if (str_starts_with($name, $prefix . '256-256.') && !$crop) {
+                                       // Uncropped image
+                                       return $node;
+                               }
                        }
                }