mirror of
https://github.com/nextcloud/server.git
synced 2025-02-18 06:53:07 +00:00
fix(OC_Files): Fix error response when event
was not set
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
2d986d50d8
commit
66521dbfeb
1 changed files with 8 additions and 4 deletions
|
@ -13,6 +13,7 @@ use OCP\Files\Events\BeforeDirectFileDownloadEvent;
|
|||
use OCP\Files\Events\BeforeZipCreatedEvent;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Lock\ILockingProvider;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class for file server access
|
||||
|
@ -202,12 +203,15 @@ class OC_Files {
|
|||
die();
|
||||
} catch (\Exception $ex) {
|
||||
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
|
||||
OC::$server->getLogger()->logException($ex);
|
||||
$l = \OC::$server->getL10N('lib');
|
||||
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
|
||||
if ($event && $event->getErrorMessage() !== null) {
|
||||
$logger = \OCP\Server::get(LoggerInterface::class);
|
||||
$logger->error($ex->getMessage(), ['exception' => $ex]);
|
||||
$l = \OCP\Server::get(\OCP\L10N\IFactory::class)->get('lib');
|
||||
|
||||
$hint = ($ex instanceof \OCP\HintException) ? $x->getHint() : '';
|
||||
if (isset($event) && $event->getErrorMessage() !== null) {
|
||||
$hint .= ' ' . $event->getErrorMessage();
|
||||
}
|
||||
|
||||
\OC_Template::printErrorPage($l->t('Cannot download file'), $hint, 200);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue