summaryrefslogtreecommitdiffstats
path: root/lib/private/preview.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-07-17 13:25:09 +0200
committerRobin Appelman <icewind@owncloud.com>2015-10-01 13:14:47 +0200
commit9925ff33f10bbece12816c0638756eb0e6ddbe92 (patch)
treeb03f52bf45792ce080060087f6d5446a2d6e061c /lib/private/preview.php
parent52d4495793377c8eb2c2cdabf8ec8b8cce2dd9d1 (diff)
downloadnextcloud-server-9925ff33f10bbece12816c0638756eb0e6ddbe92.tar.gz
nextcloud-server-9925ff33f10bbece12816c0638756eb0e6ddbe92.zip
use cache data we already have to check if a thumbnail of specific size is cached
Diffstat (limited to 'lib/private/preview.php')
-rw-r--r--lib/private/preview.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php
index e445f5356a4..dabb274323f 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -479,7 +479,7 @@ class Preview {
$preview = $this->buildCachePath($fileId, $previewWidth, $previewHeight);
// This checks if we have a preview of those exact dimensions in the cache
- if ($this->userView->file_exists($preview)) {
+ if ($this->thumbnailSizeExists($allThumbnails, $previewWidth, $previewHeight)) {
return $preview;
}
@@ -525,6 +525,29 @@ class Preview {
}
/**
+ * Check if a specific thumbnail size is cached
+ *
+ * @param FileInfo[] $allThumbnails the list of all our cached thumbnails
+ * @param int $width
+ * @param int $height
+ * @return bool
+ */
+ private function thumbnailSizeExists($allThumbnails, $width, $height) {
+
+ foreach ($allThumbnails as $thumbnail) {
+ $name = $thumbnail['name'];
+ if (strpos($name, 'max')) {
+ list($cachedWidth, $cachedHeight) = $this->getDimensionsFromFilename($name);
+ if ($cachedWidth === $width && $cachedHeight === $height) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
* Determines the size of the preview we should be looking for in the cache
*
* @return int[]