fix(manga): générer le CBZ de téléchargement depuis les dossiers de pages

Les endpoints de téléchargement chapitre/volume plantaient (500 "file does
not exist") car le FileService traitait `pagesDirectory` comme un CBZ. Le
service reconstruit maintenant l'archive à la volée à partir des images du
dossier, et le nom du fichier chapitre inclut le titre du manga et le numéro.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jérémy Guillot
2026-04-09 14:48:17 +02:00
parent 848efd3327
commit 41c1fc5e2e
6 changed files with 77 additions and 55 deletions

View File

@@ -27,7 +27,7 @@ class DownloadCbzTest extends AbstractApiTestCase
'number' => 1.0,
'title' => 'Chapter 1',
'visible' => true,
'cbzPath' => '/app/tests/Shared/Files/test-chapter.cbz',
'pagesDirectory' => '/app/tests/Shared/Files/test-pages',
]);
$chapterId = $chapter->getId();
@@ -41,7 +41,7 @@ class DownloadCbzTest extends AbstractApiTestCase
$response = static::getClient()->getResponse();
$this->assertEquals('application/x-cbz', $response->headers->get('Content-Type'));
$this->assertStringContainsString('attachment; filename=', $response->headers->get('Content-Disposition'));
$this->assertStringContainsString('test-chapter.cbz', $response->headers->get('Content-Disposition'));
$this->assertStringContainsString('Ch.001.cbz', $response->headers->get('Content-Disposition'));
}
public function testItReturns404ForNonExistentChapter(): void

View File

@@ -27,7 +27,7 @@ class DownloadVolumeTest extends AbstractApiTestCase
'manga' => $manga,
'volume' => 1,
'visible' => true,
'cbzPath' => __DIR__.'/../../Shared/Files/test-chapter.cbz',
'pagesDirectory' => __DIR__.'/../../Shared/Files/test-pages',
]);
$mangaId = $manga->getId();
@@ -108,7 +108,7 @@ class DownloadVolumeTest extends AbstractApiTestCase
'volume' => 1,
'number' => 1.0,
'visible' => true,
'cbzPath' => __DIR__.'/../../Shared/Files/test-chapter.cbz',
'pagesDirectory' => __DIR__.'/../../Shared/Files/test-pages',
]);
ChapterFactory::createOne([
@@ -116,7 +116,7 @@ class DownloadVolumeTest extends AbstractApiTestCase
'volume' => 1,
'number' => 2.0,
'visible' => false, // Soft deleted
'cbzPath' => __DIR__.'/../../Shared/Files/test-chapter.cbz',
'pagesDirectory' => __DIR__.'/../../Shared/Files/test-pages',
]);
ChapterFactory::createOne([
@@ -132,7 +132,7 @@ class DownloadVolumeTest extends AbstractApiTestCase
'volume' => 1,
'number' => 4.0,
'visible' => true,
'cbzPath' => __DIR__.'/../../Shared/Files/test-chapter.cbz',
'pagesDirectory' => __DIR__.'/../../Shared/Files/test-pages',
]);
$mangaId = $manga->getId();

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B