Skip to content

Commit 72e5d6d

Browse files
committed
fix(OC_Files): Fix error response when event was not set
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 2f1d14a commit 72e5d6d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/private/legacy/OC_Files.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCP\Files\Events\BeforeZipCreatedEvent;
1414
use OCP\Files\IRootFolder;
1515
use OCP\Lock\ILockingProvider;
16+
use Psr\Log\LoggerInterface;
1617

1718
/**
1819
* Class for file server access
@@ -202,12 +203,15 @@ public static function get($dir, $files, $params = null) {
202203
die();
203204
} catch (\Exception $ex) {
204205
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
205-
OC::$server->getLogger()->logException($ex);
206-
$l = \OC::$server->getL10N('lib');
207-
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
208-
if ($event && $event->getErrorMessage() !== null) {
206+
$logger = \OCP\Server::get(LoggerInterface::class);
207+
$logger->error($ex->getMessage(), ['exception' => $ex]);
208+
$l = \OCP\Server::get(\OCP\L10N\IFactory::class)->get('lib');
209+
210+
$hint = ($ex instanceof \OCP\HintException) ? $ex->getHint() : '';
211+
if (isset($event) && $event->getErrorMessage() !== null) {
209212
$hint .= ' ' . $event->getErrorMessage();
210213
}
214+
211215
\OC_Template::printErrorPage($l->t('Cannot download file'), $hint, 200);
212216
}
213217
}

0 commit comments

Comments
 (0)