summaryrefslogtreecommitdiffstats
path: root/lib/private/Preview/Generator.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-03-19 20:23:23 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2017-03-19 20:23:23 +0100
commit4cd13e76685f498c4f344bc786ecc8fe2cf91f7a (patch)
tree36bd4ee32e18d09f1b2876269b5636ac3a328c25 /lib/private/Preview/Generator.php
parent6677963902297d95dd7f73854e2a6b1ea3873a4e (diff)
downloadnextcloud-server-4cd13e76685f498c4f344bc786ecc8fe2cf91f7a.tar.gz
nextcloud-server-4cd13e76685f498c4f344bc786ecc8fe2cf91f7a.zip
Don't generate max preview twice
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>
Diffstat (limited to 'lib/private/Preview/Generator.php')
-rw-r--r--lib/private/Preview/Generator.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 32a732d8580..9ccf6aaf4fe 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -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);