Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/Command/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

namespace OCA\PreviewGenerator\Command;

use OC\DB\Exceptions\DbalException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\PreviewGenerator\Model\WorkerConfig;
use OCA\PreviewGenerator\Service\ModuloService;
use OCA\PreviewGenerator\SizeHelper;
use OCP\DB\Exception;
use OCP\Encryption\IManager;
use OCP\Files\File;
use OCP\Files\Folder;
Expand Down Expand Up @@ -309,6 +311,13 @@ private function parseFile(File $file): void {
$class = $e::class;
$error = $e->getMessage();
$this->output->writeln("<error>{$class}: {$error}</error>");
} catch (DbalException $e) {
// Since the introduction of the oc_previews table, preview duplication caused by
// duplicated specifications will cause a UniqueConstraintViolationException. We can
// simply ignore this exception here and carry on.
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions lib/Command/PreGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

namespace OCA\PreviewGenerator\Command;

use OC\DB\Exceptions\DbalException;
use OCA\PreviewGenerator\Service\NoMediaService;
use OCA\PreviewGenerator\SizeHelper;
use OCP\AppFramework\Db\TTransactional;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\Exception;
use OCP\Encryption\IManager;
use OCP\Files\File;
use OCP\Files\GenericFileException;
Expand Down Expand Up @@ -197,6 +199,13 @@ private function processFile(File $file): void {
$class = $e::class;
$error = $e->getMessage();
$this->output->writeln("<error>{$class}: {$error}</error>");
} catch (DbalException $e) {
// Since the introduction of the oc_previews table, preview duplication caused by
// duplicated specifications will cause a UniqueConstraintViolationException. We can
// simply ignore this exception here and carry on.
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
}
}
}
Expand Down
Loading