Merge pull request #13179 from owncloud/fix-fatal-php-error-for-not-existing-files
Verify whether type is correct
This commit is contained in:
commit
6c59253978
|
@ -29,21 +29,17 @@ if ($maxX === 0 || $maxY === 0) {
|
|||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$preview = new \OC\Preview(\OC_User::getUser(), 'files');
|
||||
$info = \OC\Files\Filesystem::getFileInfo($file);
|
||||
if (!$always and !$preview->isAvailable($info)) {
|
||||
\OC_Response::setStatus(404);
|
||||
} else {
|
||||
$preview->setFile($file);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingUp);
|
||||
$preview->setKeepAspect($keepAspect);
|
||||
$preview->showPreview();
|
||||
}
|
||||
$preview = new \OC\Preview(\OC_User::getUser(), 'files');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
|
||||
$info = \OC\Files\Filesystem::getFileInfo($file);
|
||||
|
||||
if (!$info instanceof OCP\Files\FileInfo || !$always && !$preview->isAvailable($info)) {
|
||||
\OC_Response::setStatus(404);
|
||||
} else {
|
||||
$preview->setFile($file);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingUp);
|
||||
$preview->setKeepAspect($keepAspect);
|
||||
$preview->showPreview();
|
||||
}
|
||||
|
|
|
@ -200,14 +200,15 @@ class Preview {
|
|||
/**
|
||||
* set the path of the file you want a thumbnail from
|
||||
* @param string $file
|
||||
* @return \OC\Preview $this
|
||||
* @return $this
|
||||
*/
|
||||
public function setFile($file) {
|
||||
$this->file = $file;
|
||||
$this->info = null;
|
||||
|
||||
if ($file !== '') {
|
||||
$this->getFileInfo();
|
||||
if($this->info !== null && $this->info !== false) {
|
||||
if($this->info instanceof \OCP\Files\FileInfo) {
|
||||
$this->mimeType = $this->info->getMimetype();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue