diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2022-05-10 10:11:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 10:11:24 +0200 |
commit | 0863a3d4238467299fba1dce995d834b8cdc9ad2 (patch) | |
tree | 19fbb06373e06ecfbe3b9094d77d751ffe5e8dd2 | |
parent | 8f989bb489be5fea5d0b93f748edb6bac46e6e4b (diff) | |
parent | 982c846b11147f1c7357e1d8cbd45d55318e3655 (diff) | |
download | nextcloud-server-0863a3d4238467299fba1dce995d834b8cdc9ad2.tar.gz nextcloud-server-0863a3d4238467299fba1dce995d834b8cdc9ad2.zip |
Merge pull request #32315 from nextcloud/fix/noid/preview-duplicate-folder-creation
-rw-r--r-- | lib/private/Preview/Generator.php | 12 |
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; |