From f56ae37e8fe31afb109889816273c21704361f15 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 9 Sep 2016 10:58:52 +0200 Subject: Opening the trashbin causes errors in log for files without preview * put a file without a generated preview in the trashbin (e.g. a *.docx file) * open the trashbin * following errors will show up in the nextcloud.log: - filesize(): stat failed for ... - fopen(...): failed to open stream: No such file or directory at ... - fread() expects parameter 1 to be resource, boolean given at ... - fclose() expects parameter 1 to be resource, boolean given at ... - imagecreatefromstring(): Empty string or invalid image at ... This is because the preview code tries to load an SVG image, which is obviously only text. The fix simply handles this before the loading happens and the web UI keeps showing the default mimetype icon. --- apps/files_trashbin/ajax/preview.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apps/files_trashbin/ajax') diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php index 1a0131da28c..3f895161f00 100644 --- a/apps/files_trashbin/ajax/preview.php +++ b/apps/files_trashbin/ajax/preview.php @@ -72,6 +72,8 @@ try{ $preview->setScalingUp($scalingUp); $preview->showPreview(); +} catch (\OC\PreviewNotAvailableException $e) { + \OC_Response::setStatus(404); }catch(\Exception $e) { \OC_Response::setStatus(500); \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::DEBUG); -- cgit v1.2.3