diff options
author | szaimen <szaimen@e.mail.de> | 2022-10-30 13:43:22 +0100 |
---|---|---|
committer | Bowen Ding <6999708+dbw9580@users.noreply.github.com> | 2022-11-05 16:03:01 +0800 |
commit | f9e9cd270dc1e6a7a6a7396b2f1af03512f81738 (patch) | |
tree | 9275419c3ac5910a5bfa2e742944789971762995 /lib/private/PreviewManager.php | |
parent | c88aabd1252c00dad59f143853042fc05ebc8d40 (diff) | |
download | nextcloud-server-f9e9cd270dc1e6a7a6a7396b2f1af03512f81738.tar.gz nextcloud-server-f9e9cd270dc1e6a7a6a7396b2f1af03512f81738.zip |
Limit-number-of-concurrent-preview-generations
Signed-off-by: Bowen Ding <dbw9580@live.com>
Signed-off-by: szaimen <szaimen@e.mail.de>
Diffstat (limited to 'lib/private/PreviewManager.php')
-rw-r--r-- | lib/private/PreviewManager.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 0d08ef3eba5..87e709e9bcc 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -182,7 +182,15 @@ class PreviewManager implements IPreview { * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0 */ public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null) { - return $this->getGenerator()->getPreview($file, $width, $height, $crop, $mode, $mimeType); + $previewConcurrency = $this->getGenerator()->getNumConcurrentPreviews('preview_concurrency_all'); + $sem = Generator::guardWithSemaphore(Generator::SEMAPHORE_ID_ALL, $previewConcurrency); + try { + $preview = $this->getGenerator()->getPreview($file, $width, $height, $crop, $mode, $mimeType); + } finally { + Generator::unguardWithSemaphore($sem); + } + + return $preview; } /** |