From f66d200e29953027f967713caeca47017adf9b1f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 1 May 2017 14:28:14 +0200 Subject: [PATCH 1/2] handle failed preview generation --- lib/Command/Generate.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Command/Generate.php b/lib/Command/Generate.php index 24acf41..79bf132 100644 --- a/lib/Command/Generate.php +++ b/lib/Command/Generate.php @@ -20,6 +20,7 @@ * along with this program. If not, see . * */ + namespace OCA\PreviewGenerator\Command; use OCP\Encryption\IManager; @@ -68,10 +69,10 @@ class Generate extends Command { * @param IManager $encryptionManager */ public function __construct(IRootFolder $rootFolder, - IUserManager $userManager, - IPreview $previewGenerator, - IConfig $config, - IManager $encryptionManager) { + IUserManager $userManager, + IPreview $previewGenerator, + IConfig $config, + IManager $encryptionManager) { parent::__construct(); $this->userManager = $userManager; @@ -133,19 +134,19 @@ private function calculateSizes() { $maxH = (int)$this->config->getSystemValue('preview_max_y', 2048); $s = 32; - while($s <= $maxW || $s <= $maxH) { + while ($s <= $maxW || $s <= $maxH) { $this->sizes['square'][] = $s; $s *= 2; } $w = 32; - while($w <= $maxW) { + while ($w <= $maxW) { $this->sizes['width'][] = $w; $w *= 2; } $h = 32; - while($h <= $maxH) { + while ($h <= $maxH) { $this->sizes['height'][] = $h; $h *= 2; } @@ -204,6 +205,9 @@ private function parseFile(File $file) { } } catch (NotFoundException $e) { // Maybe log that previews could not be generated? + } catch (\InvalidArgumentException $e) { + $error = $e->getMessage(); + $this->output->writeln("${error}"); } } } From e8096ac299f87459c263a993e5d983cb94897f7a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 2 May 2017 13:38:49 +0200 Subject: [PATCH 2/2] error handling in pre-generate --- lib/Command/PreGenerate.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Command/PreGenerate.php b/lib/Command/PreGenerate.php index 036e80e..94f4e0e 100644 --- a/lib/Command/PreGenerate.php +++ b/lib/Command/PreGenerate.php @@ -224,6 +224,9 @@ private function processFile(File $file) { } } catch (NotFoundException $e) { // Maybe log that previews could not be generated? + } catch (\InvalidArgumentException $e) { + $error = $e->getMessage(); + $this->output->writeln("${error}"); } }