aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/PreviewManager.php
diff options
context:
space:
mode:
authorszaimen <szaimen@e.mail.de>2022-10-30 13:43:22 +0100
committerBowen Ding <6999708+dbw9580@users.noreply.github.com>2022-11-05 16:03:01 +0800
commitf9e9cd270dc1e6a7a6a7396b2f1af03512f81738 (patch)
tree9275419c3ac5910a5bfa2e742944789971762995 /lib/private/PreviewManager.php
parentc88aabd1252c00dad59f143853042fc05ebc8d40 (diff)
downloadnextcloud-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.php10
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;
}
/**