Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip errors that may interrupt file creation #4360

Merged
merged 3 commits into from
Dec 30, 2024
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
10 changes: 8 additions & 2 deletions lib/Listener/FileCreatedFromTemplateListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Template\FileCreatedFromTemplateEvent;
use Psr\Log\LoggerInterface;

/** @template-implements IEventListener<Event|FileCreatedFromTemplateEvent> */
class FileCreatedFromTemplateListener implements IEventListener {
Expand All @@ -24,6 +25,7 @@ public function __construct(
private TemplateManager $templateManager,
private TemplateFieldService $templateFieldService,
private CapabilitiesService $capabilitiesService,
private LoggerInterface $logger,
) {
}

Expand Down Expand Up @@ -58,8 +60,12 @@ public function handle(Event $event): void {
}

if ($this->capabilitiesService->hasFormFilling()) {
$filledTemplate = $this->templateFieldService->fillFields($templateFile, $event->getTemplateFields());
$event->getTarget()->putContent($filledTemplate);
try {
$filledTemplate = $this->templateFieldService->fillFields($templateFile, $event->getTemplateFields());
$event->getTarget()->putContent($filledTemplate);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
}
}

// Avoid having the mimetype of the source file set
Expand Down
11 changes: 9 additions & 2 deletions lib/Service/RemoteOptionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@

namespace OCA\Richdocuments\Service;

use OCP\IAppConfig;

class RemoteOptionsService {
public const REMOTE_TIMEOUT_DEFAULT = 5;

public static function getDefaultOptions(int $timeout = self::REMOTE_TIMEOUT_DEFAULT): array {
return [
$options = [
'timeout' => $timeout,
'nextcloud' => [
'allow_local_address' => true,
]
];
}

if (\OCP\Server::get(IAppConfig::class)->getValueString('richdocuments', 'disable_certificate_verification') === 'yes') {
$options['verify'] = false;
}

return $options;
}
}
Loading
Loading