]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't generate max preview twice
authorRoeland Jago Douma <roeland@famdouma.nl>
Sun, 19 Mar 2017 19:23:23 +0000 (20:23 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Sun, 19 Mar 2017 19:23:23 +0000 (20:23 +0100)
If you request a preview of X by Y. And after calculating X and Y are
equal to maxWidth and maxHeight then there is no reason to create a
preview of that size.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/Preview/Generator.php

index 32a732d8580cdb55a1f0bc8bbc3edcad86fde73f..9ccf6aaf4fe29694dcaea657158d99a9b24791f0 100644 (file)
@@ -111,6 +111,11 @@ class Generator {
                // Calculate the preview size
                list($width, $height) = $this->calculateSize($width, $height, $crop, $mode, $maxWidth, $maxHeight);
 
+               // No need to generate a preview that is just the max preview
+               if ($width === $maxWidth && $height === $maxHeight) {
+                       return $maxPreview;
+               }
+
                // Try to get a cached preview. Else generate (and store) one
                try {
                        $file = $this->getCachedPreview($previewFolder, $width, $height, $crop);