Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-05-16 12:55:14 +0300
committerGitHub <noreply@github.com>2022-05-16 12:55:14 +0300
commit5e7d10aa8cfd9ad63cd4dbd78fc16651ae86180a (patch)
tree27425d9a69664fdcb52d1a95bf1d7e6c48b62c03
parentd7482c8a39ddfa8c9f2671012d20128a9888a4e5 (diff)
parent8fcef8848a156cd2e0013a0efc31a60775b7fb88 (diff)
Merge pull request #32320 from nextcloud/backport/32315/stable24
[stable24] Fix preview generator trying to recreate an existing folder
-rw-r--r--lib/private/Preview/Generator.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index cef3fa4039a..e058a15bfa5 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -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;