diff options
author | Robin Appelman <robin@icewind.nl> | 2015-10-01 16:24:29 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2015-10-01 16:24:29 +0200 |
commit | 8ae4f5bf1a8adaac41715e2b5f1914ef899a09b6 (patch) | |
tree | edf1270f7b3fc440b9e43a9e31e2b5bffe95b0be /lib | |
parent | 64994facce890e53a50bc75047e502e434c9c749 (diff) | |
parent | 1c3e28a73b602423dfc4ba447b26dcd3b8b45fac (diff) | |
download | nextcloud-server-8ae4f5bf1a8adaac41715e2b5f1914ef899a09b6.tar.gz nextcloud-server-8ae4f5bf1a8adaac41715e2b5f1914ef899a09b6.zip |
Merge pull request #17703 from owncloud/preview-better-cache-use
Better cache usage for previews
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/preview.php | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php index 1127048b7fd..b2accdfd00f 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -252,12 +252,13 @@ class Preview { * Sets the path of the file you want a preview of * * @param string $file + * @param \OCP\Files\FileInfo|null $info * * @return \OC\Preview */ - public function setFile($file) { + public function setFile($file, $info = null) { $this->file = $file; - $this->info = null; + $this->info = $info; if ($file !== '') { $this->getFileInfo(); @@ -374,7 +375,7 @@ class Preview { return false; } - if (!$this->fileView->file_exists($file)) { + if (!$this->getFileInfo() instanceof FileInfo) { \OCP\Util::writeLog('core', 'File:"' . $file . '" not found', \OCP\Util::DEBUG); return false; @@ -478,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, basename($preview))) { return $preview; } @@ -524,6 +525,24 @@ class Preview { } /** + * Check if a specific thumbnail size is cached + * + * @param FileInfo[] $allThumbnails the list of all our cached thumbnails + * @param string $name + * @return bool + */ + private function thumbnailSizeExists(array $allThumbnails, $name) { + + foreach ($allThumbnails as $thumbnail) { + if ($name === $thumbnail->getName()) { + return true; + } + } + + return false; + } + + /** * Determines the size of the preview we should be looking for in the cache * * @return int[] |