summaryrefslogtreecommitdiffstats
path: root/lib/private/PreviewManager.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-04-10 15:57:06 +0200
committerGitHub <noreply@github.com>2020-04-10 15:57:06 +0200
commiteba3726e1e1b7ce0a98df4552cfdecfe05e0d63a (patch)
tree7d50a939305460fbb34078c1da49f992552747e7 /lib/private/PreviewManager.php
parentedf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff)
parent8f9bac26f874e105c017de2b1791b23c2a135b28 (diff)
downloadnextcloud-server-eba3726e1e1b7ce0a98df4552cfdecfe05e0d63a.tar.gz
nextcloud-server-eba3726e1e1b7ce0a98df4552cfdecfe05e0d63a.zip
Merge pull request #19495 from nextcloud/preview-generate-batch
optimize batch generation of previews
Diffstat (limited to 'lib/private/PreviewManager.php')
-rw-r--r--lib/private/PreviewManager.php44
1 files changed, 31 insertions, 13 deletions
diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php
index adfc04199e3..0734e275926 100644
--- a/lib/private/PreviewManager.php
+++ b/lib/private/PreviewManager.php
@@ -151,6 +151,22 @@ class PreviewManager implements IPreview {
return !empty($this->providers);
}
+ private function getGenerator(): Generator {
+ if ($this->generator === null) {
+ $this->generator = new Generator(
+ $this->config,
+ $this,
+ $this->appData,
+ new GeneratorHelper(
+ $this->rootFolder,
+ $this->config
+ ),
+ $this->eventDispatcher
+ );
+ }
+ return $this->generator;
+ }
+
/**
* Returns a preview of a file
*
@@ -169,20 +185,22 @@ 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) {
- if ($this->generator === null) {
- $this->generator = new Generator(
- $this->config,
- $this,
- $this->appData,
- new GeneratorHelper(
- $this->rootFolder,
- $this->config
- ),
- $this->eventDispatcher
- );
- }
+ return $this->getGenerator()->getPreview($file, $width, $height, $crop, $mode, $mimeType);
+ }
- return $this->generator->getPreview($file, $width, $height, $crop, $mode, $mimeType);
+ /**
+ * Generates previews of a file
+ *
+ * @param File $file
+ * @param array $specifications
+ * @param string $mimeType
+ * @return ISimpleFile the last preview that was generated
+ * @throws NotFoundException
+ * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
+ * @since 19.0.0
+ */
+ public function generatePreviews(File $file, array $specifications, $mimeType = null) {
+ return $this->getGenerator()->generatePreviews($file, $specifications, $mimeType);
}
/**