Cache result for isMimeTypeSupported()
This commit is contained in:
parent
e518eacba6
commit
e38dea3542
1 changed files with 13 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue