diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-03-13 09:55:13 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-03-16 12:44:12 +0100 |
commit | 3b7aec1b7d4e2e3a1ff6c1f7888189c67aa09b75 (patch) | |
tree | 96ee940993ab8c8f4bf2cc790589eaab128559f5 /lib/private/previewmanager.php | |
parent | 37b827f0b2139ce668a4e394188f24283c14d643 (diff) | |
download | nextcloud-server-3b7aec1b7d4e2e3a1ff6c1f7888189c67aa09b75.tar.gz nextcloud-server-3b7aec1b7d4e2e3a1ff6c1f7888189c67aa09b75.zip |
Only sort the list when required
Diffstat (limited to 'lib/private/previewmanager.php')
-rw-r--r-- | lib/private/previewmanager.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/private/previewmanager.php b/lib/private/previewmanager.php index 81fa1baad61..0d3ec40c06b 100644 --- a/lib/private/previewmanager.php +++ b/lib/private/previewmanager.php @@ -16,6 +16,9 @@ class PreviewManager implements IPreview { protected $config; /** @var array */ + protected $providerListDirty = false; + + /** @var array */ protected $providers = []; /** @var array mime type => support status */ @@ -57,6 +60,7 @@ class PreviewManager implements IPreview { $this->providers[$mimeTypeRegex] = []; } $this->providers[$mimeTypeRegex][] = $callable; + $this->providerListDirty = true; } /** @@ -64,8 +68,15 @@ class PreviewManager implements IPreview { * @return array */ public function getProviders() { - $keys = array_map('strlen', array_keys($this->providers)); - array_multisort($keys, SORT_DESC, $this->providers); + if (!$this->config->getSystemValue('enable_previews', true)) { + return []; + } + + if ($this->providerListDirty) { + $keys = array_map('strlen', array_keys($this->providers)); + array_multisort($keys, SORT_DESC, $this->providers); + $this->providerListDirty = false; + } return $this->providers; } |