From 51c6cd5c6a725b4849d995049163a0b87a9c3a58 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 14 Dec 2015 15:59:36 +0100 Subject: Handle non existing files in version previews --- apps/files_versions/ajax/preview.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'apps') diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php index 8ad0fe58306..fd7ae967515 100644 --- a/apps/files_versions/ajax/preview.php +++ b/apps/files_versions/ajax/preview.php @@ -45,14 +45,18 @@ if($maxX === 0 || $maxY === 0) { try { list($user, $file) = \OCA\Files_Versions\Storage::getUidAndFilename($file); - $preview = new \OC\Preview($user, 'files_versions', $file.'.v'.$version); - $mimetype = \OC_Helper::getFileNameMimeType($file); - $preview->setMimetype($mimetype); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingUp); + if (is_null($file)) { + \OC_Response::setStatus(404); + } else { + $preview = new \OC\Preview($user, 'files_versions', $file . '.v' . $version); + $mimetype = \OC_Helper::getFileNameMimeType($file); + $preview->setMimetype($mimetype); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); - $preview->showPreview(); + $preview->showPreview(); + } }catch(\Exception $e) { \OC_Response::setStatus(500); \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); -- cgit v1.2.3