]> source.dussan.org Git - nextcloud-server.git/commitdiff
Cache result for isMimeTypeSupported()
authorJoas Schilling <nickvergessen@owncloud.com>
Fri, 13 Mar 2015 08:39:16 +0000 (09:39 +0100)
committerJoas Schilling <nickvergessen@owncloud.com>
Mon, 16 Mar 2015 11:44:11 +0000 (12:44 +0100)
lib/private/previewmanager.php

index c940307084d3d711b00e38631113006cfce51b31..9f83d88a1fea7fc3bbceeed4282e8035f773910c 100644 (file)
@@ -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;