diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-03-13 09:39:16 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-03-16 12:44:11 +0100 |
commit | e38dea3542ee48c6ad51808fc28d9d098cc804b2 (patch) | |
tree | 8edc0643f23214963053573cb593758f8b46ff62 /lib/private/previewmanager.php | |
parent | e518eacba6837a059381e1ffa2af4a10eba0e8ae (diff) | |
download | nextcloud-server-e38dea3542ee48c6ad51808fc28d9d098cc804b2.tar.gz nextcloud-server-e38dea3542ee48c6ad51808fc28d9d098cc804b2.zip |
Cache result for isMimeTypeSupported()
Diffstat (limited to 'lib/private/previewmanager.php')
-rw-r--r-- | lib/private/previewmanager.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/previewmanager.php b/lib/private/previewmanager.php index c940307084d..9f83d88a1fe 100644 --- a/lib/private/previewmanager.php +++ b/lib/private/previewmanager.php @@ -18,6 +18,9 @@ class PreviewManager implements IPreview { /** @var array */ protected $providers = []; + /** @var array mime type => support status */ + protected $mimeTypeSupportMap = []; + /** @var array */ protected $defaultProviders; @@ -96,12 +99,18 @@ class PreviewManager implements IPreview { return false; } + if (isset($this->mimeTypeSupportMap[$mimeType])) { + return $this->mimeTypeSupportMap[$mimeType]; + } + $providerMimeTypes = array_keys($this->providers); foreach ($providerMimeTypes as $supportedMimeType) { if (preg_match($supportedMimeType, $mimeType)) { + $this->mimeTypeSupportMap[$mimeType] = true; return true; } } + $this->mimeTypeSupportMap[$mimeType] = false; return false; } @@ -116,6 +125,10 @@ class PreviewManager implements IPreview { return false; } + if (!$this->isMimeSupported($file->getMimetype())) { + return false; + } + $mount = $file->getMountPoint(); if ($mount and !$mount->getOption('previews', true)){ return false; |