Skip to content

Commit

Permalink
Merge pull request #32315 from nextcloud/fix/noid/preview-duplicate-f…
Browse files Browse the repository at this point in the history
…older-creation
  • Loading branch information
skjnldsv authored May 10, 2022
2 parents 8f989bb + 982c846 commit 0863a3d
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 @@ -549,12 +550,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 0863a3d

Please sign in to comment.