Skip to content

Commit

Permalink
Merge pull request #51 from icewind1991/error-handling
Browse files Browse the repository at this point in the history
handle failed preview generation
  • Loading branch information
rullzer authored May 2, 2017
2 parents d39f3c4 + e8096ac commit f4a3d9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/Command/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\PreviewGenerator\Command;

use OCP\Encryption\IManager;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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>${error}</error>");
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Command/PreGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>${error}</error>");
}
}

Expand Down

0 comments on commit f4a3d9c

Please sign in to comment.