From 56011dbfdae47022dc6abae5395f3b6cc2dbd1ac Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 11 May 2022 21:58:13 +0200 Subject: [PATCH 1/3] Fix bug that thumbnail file needs to be created if not yet existing Signed-off-by: Christian Wolf --- lib/Helper/ImageService/ThumbnailFileHelper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Helper/ImageService/ThumbnailFileHelper.php b/lib/Helper/ImageService/ThumbnailFileHelper.php index 7e6bc0511..42604547a 100644 --- a/lib/Helper/ImageService/ThumbnailFileHelper.php +++ b/lib/Helper/ImageService/ThumbnailFileHelper.php @@ -89,7 +89,11 @@ private function recreateSingleThumbnail(Folder $recipeFolder, int $type): void if ($this->fileHelper->hasImage($recipeFolder)) { $full = $this->fileHelper->getImage($recipeFolder); - $file = $recipeFolder->get($filename); + if ($recipeFolder->nodeExists($filename)) { + $file = $recipeFolder->get($filename); + } else { + $file = $recipeFolder->newFile($filename); + } $this->generationHelper->generateThumbnail($full, $type, $file); } else { From 598c4a70ff4190a69555698586f0f1683583931f Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 11 May 2022 22:03:02 +0200 Subject: [PATCH 2/3] Include number of new files to test case Signed-off-by: Christian Wolf --- .../Unit/Helper/ImageService/ThumbnailFileHelperTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php b/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php index e601da330..e774b93b8 100644 --- a/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php +++ b/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php @@ -198,11 +198,18 @@ public function testRecreateThumbnails($thumbExists, $miniExists) { ]; $f->method('get')->willReturnMap($fileMap); + $cnt = 0; + if (! $thumbExists) { + $cnt ++; + } + if (! $miniExists) { + $cnt ++; + } $newFileMap = [ ['thumb.jpg', null, $thumb], ['thumb16.jpg', null, $mini], ]; - $f->method('newFile')->willReturnMap($newFileMap); + $f->expects($this->exactly($cnt))->method('newFile')->willReturnMap($newFileMap); $full = $this->createStub(File::class); $this->fileHelper->method('hasImage')->willReturn(true); From ab69e3a88f39cd4ddc9ed341381727f9fb3c9783 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 11 May 2022 22:04:39 +0200 Subject: [PATCH 3/3] Update changelog Signed-off-by: Christian Wolf --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22394a843..5bacd5195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ [#965](https://github.com/nextcloud/cookbook/pull/965) @christianlupus - Mark cookbook app as compatible with NC24 [#977](https://github.com/nextcloud/cookbook/pull/977) @christianlupus +- Fix bug that prevent generation of thumbnails when no previous thumbnails are present + [#985](https://github.com/nextcloud/cookbook/pull/985) @christianlupus ### Documentation - Corrected some spelling issues