Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix preview generator trying to recreate an existing folder
Signed-off-by: Richard Steinmetz <[email protected]>
  • Loading branch information
st3iny authored and backportbot-nextcloud[bot] committed May 10, 2022
commit 8fcef8848a156cd2e0013a0efc31a60775b7fb88
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