Cache result for isMimeTypeSupported()

This commit is contained in:
Joas Schilling 2015-03-13 09:39:16 +01:00
parent e518eacba6
commit e38dea3542

View 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;