]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix preview generator trying to recreate an existing folder 32315/head
authorRichard Steinmetz <richard@steinmetz.cloud>
Mon, 9 May 2022 14:54:57 +0000 (16:54 +0200)
committerRichard Steinmetz <richard@steinmetz.cloud>
Mon, 9 May 2022 15:30:07 +0000 (17:30 +0200)
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
lib/private/Preview/Generator.php

index cef3fa4039ae79693f45d52713975aab5ce2e3ae..e058a15bfa5536a6a7891f41850e34e7b2527a4b 100644 (file)
@@ -31,6 +31,7 @@ namespace OC\Preview;
 
 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;
@@ -549,12 +550,19 @@ class Generator {
         *
         * @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;