fix song downloading from gui

This commit is contained in:
raiper34
2024-09-01 17:39:46 +02:00
parent 2a01e7e09a
commit 469fedbb0d
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ export class TrackController {
async getFile(@Res({ passthrough: true }) res: Response, @Param('id') id: number): Promise<StreamableFile> { async getFile(@Res({ passthrough: true }) res: Response, @Param('id') id: number): Promise<StreamableFile> {
const track = await this.service.findOne(id); const track = await this.service.findOne(id);
const fileName = `${track.artist} - ${track.song}.${this.configService.get<string>(EnviromentEnum.FORMAT)}`; const fileName = `${track.artist} - ${track.song}.${this.configService.get<string>(EnviromentEnum.FORMAT)}`;
const filePath = createReadStream(resolve(__dirname, '..', this.configService.get<string>(EnviromentEnum.DOWNLOADS_PATH), fileName)); const filePath = createReadStream(resolve(__dirname, '..', this.configService.get<string>(EnviromentEnum.DOWNLOADS_PATH), track.playlist.name, fileName));
res.set({'Content-Disposition': `attachment; filename="${fileName}`}); res.set({'Content-Disposition': `attachment; filename="${fileName}`});
return new StreamableFile(filePath); return new StreamableFile(filePath);
} }
+1 -1
View File
@@ -37,7 +37,7 @@ export class TrackService {
} }
findOne(id: number): Promise<TrackEntity | null> { findOne(id: number): Promise<TrackEntity | null> {
return this.repository.findOneBy({ id }); return this.repository.findOne({where: {id}, relations: ['playlist']});
} }
async remove(id: number): Promise<void> { async remove(id: number): Promise<void> {