Skip to content

Commit

Permalink
Fix preview generator trying to recreate an existing folder
Browse files Browse the repository at this point in the history
Backport of #32315

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
  • Loading branch information
st3iny committed May 10, 2022
1 parent 1def8bd commit 468ff90
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

use OCP\Files\File;
use OCP\Files\IAppData;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFile;
Expand Down Expand Up @@ -464,12 +465,19 @@ private function getCachedPreview(ISimpleFolder $previewFolder, $width, $height,
*
* @param File $file
* @return ISimpleFolder
*
* @throws InvalidPathException
* @throws NotFoundException
* @throws NotPermittedException
*/
private function getPreviewFolder(File $file) {
// Obtain file id outside of try catch block to prevent the creation of an existing folder
$fileId = (string)$file->getId();

try {
$folder = $this->appData->getFolder($file->getId());
$folder = $this->appData->getFolder($fileId);
} catch (NotFoundException $e) {
$folder = $this->appData->newFolder($file->getId());
$folder = $this->appData->newFolder($fileId);
}

return $folder;
Expand Down

0 comments on commit 468ff90

Please sign in to comment.