Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/previewgenerator.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-01-27 12:50:08 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-01-27 12:50:08 +0300
commit507fae431cfae7fc210920857ae81906cb69c506 (patch)
tree4fe57efc946fd77e9b4320d789f51204daf6bfb1
parent97d057825f3e69a125d194d2c19a08e1e5d68203 (diff)
Warn and carry on when storage is not available
Fixes #103 Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r--lib/Command/Generate.php32
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/Command/Generate.php b/lib/Command/Generate.php
index d66a9cb..ac705d3 100644
--- a/lib/Command/Generate.php
+++ b/lib/Command/Generate.php
@@ -31,6 +31,7 @@ use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
+use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\IPreview;
use OCP\IUser;
@@ -155,22 +156,29 @@ class Generate extends Command {
}
private function parseFolder(Folder $folder) {
- // Respect the '.nomedia' file. If present don't traverse the folder
- if ($folder->nodeExists('.nomedia')) {
- $this->output->writeln('Skipping folder ' . $folder->getPath());
- return;
- }
+ try {
+ // Respect the '.nomedia' file. If present don't traverse the folder
+ if ($folder->nodeExists('.nomedia')) {
+ $this->output->writeln('Skipping folder ' . $folder->getPath());
+ return;
+ }
- $this->output->writeln('Scanning folder ' . $folder->getPath());
+ $this->output->writeln('Scanning folder ' . $folder->getPath());
- $nodes = $folder->getDirectoryListing();
+ $nodes = $folder->getDirectoryListing();
- foreach ($nodes as $node) {
- if ($node instanceof Folder) {
- $this->parseFolder($node);
- } elseif ($node instanceof File) {
- $this->parseFile($node);
+ foreach ($nodes as $node) {
+ if ($node instanceof Folder) {
+ $this->parseFolder($node);
+ } elseif ($node instanceof File) {
+ $this->parseFile($node);
+ }
}
+ } catch (StorageNotAvailableException $e) {
+ $this->output->writeln(sprintf('<error>Storage for folder folder %s is not available: %s</error>',
+ $folder->getPath(),
+ $e->getHint()
+ ));
}
}