Skip to content

Commit 982c846

Browse files
committed
Fix preview generator trying to recreate an existing folder
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
1 parent 4f55ba2 commit 982c846

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/private/Preview/Generator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
use OCP\Files\File;
3333
use OCP\Files\IAppData;
34+
use OCP\Files\InvalidPathException;
3435
use OCP\Files\NotFoundException;
3536
use OCP\Files\NotPermittedException;
3637
use OCP\Files\SimpleFS\ISimpleFile;
@@ -549,12 +550,19 @@ private function getCachedPreview(ISimpleFolder $previewFolder, $width, $height,
549550
*
550551
* @param File $file
551552
* @return ISimpleFolder
553+
*
554+
* @throws InvalidPathException
555+
* @throws NotFoundException
556+
* @throws NotPermittedException
552557
*/
553558
private function getPreviewFolder(File $file) {
559+
// Obtain file id outside of try catch block to prevent the creation of an existing folder
560+
$fileId = (string)$file->getId();
561+
554562
try {
555-
$folder = $this->appData->getFolder($file->getId());
563+
$folder = $this->appData->getFolder($fileId);
556564
} catch (NotFoundException $e) {
557-
$folder = $this->appData->newFolder($file->getId());
565+
$folder = $this->appData->newFolder($fileId);
558566
}
559567

560568
return $folder;

0 commit comments

Comments
 (0)