Skip to content

Commit

Permalink
Merge pull request #32323 from nextcloud/fix/noid/preview-duplicate-f…
Browse files Browse the repository at this point in the history
…older-creation-stable23

[stable23] Fix preview generator trying to recreate an existing folder
  • Loading branch information
blizzz authored May 16, 2022
2 parents 9ff3b29 + 468ff90 commit 6da3fc6
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 6da3fc6

Please sign in to comment.