mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
Throw error in showPreview instead the constructor
This function is also used in a way such as:
```
$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);
}
```
Which won't work anymore since `setFile` is used instead of passing the file in the constructor. Fixes a regression in master.
This commit is contained in:
parent
079ad18bce
commit
6869d2e82a
1 changed files with 7 additions and 7 deletions
|
|
@ -111,11 +111,6 @@ class Preview {
|
|||
\OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR);
|
||||
throw new \Exception('No preview providers');
|
||||
}
|
||||
|
||||
// Check if file is valid
|
||||
if($this->isFileValid() === false) {
|
||||
throw new NotFoundException('File not found.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -540,10 +535,15 @@ class Preview {
|
|||
}
|
||||
|
||||
/**
|
||||
* show preview
|
||||
* @return void
|
||||
* @param null|string $mimeType
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
public function showPreview($mimeType = null) {
|
||||
// Check if file is valid
|
||||
if($this->isFileValid() === false) {
|
||||
throw new NotFoundException('File not found.');
|
||||
}
|
||||
|
||||
\OCP\Response::enableCaching(3600 * 24); // 24 hours
|
||||
if (is_null($this->preview)) {
|
||||
$this->getPreview();
|
||||
|
|
|
|||
Loading…
Reference in a new issue