diff --git a/back/src/artist/artist.controller.ts b/back/src/artist/artist.controller.ts index 56b4606..8077a9a 100644 --- a/back/src/artist/artist.controller.ts +++ b/back/src/artist/artist.controller.ts @@ -21,7 +21,7 @@ import { Request } from 'express'; import { ArtistService } from './artist.service'; import { Prisma, Artist } from '@prisma/client'; import { ApiTags } from '@nestjs/swagger'; -import { createReadStream } from 'fs'; +import { createReadStream, existsSync } from 'fs'; @Controller('artist') @ApiTags('artist') @@ -47,6 +47,8 @@ export class ArtistController { const artist = await this.service.get({ id }); if (!artist) throw new NotFoundException('Artist not found'); const path = `/assets/artists/${artist.name}/illustration.png`; + if (!existsSync(path)) + throw new NotFoundException('Illustration not found'); try { const file = createReadStream(path); diff --git a/back/src/genre/genre.controller.ts b/back/src/genre/genre.controller.ts index b349a44..c2d8288 100644 --- a/back/src/genre/genre.controller.ts +++ b/back/src/genre/genre.controller.ts @@ -21,7 +21,7 @@ import { Request } from 'express'; import { GenreService } from './genre.service'; import { Prisma, Genre } from '@prisma/client'; import { ApiTags } from '@nestjs/swagger'; -import { createReadStream } from 'fs'; +import { createReadStream, existsSync } from 'fs'; @Controller('genre') @ApiTags('genre') @@ -47,6 +47,8 @@ export class GenreController { const genre = await this.service.get({ id }); if (!genre) throw new NotFoundException('Genre not found'); const path = `/assets/genres/${genre.name}/illustration.png`; + if (!existsSync(path)) + throw new NotFoundException('Illustration not found'); try { const file = createReadStream(path);