Comment out file existence check and response headers for track API

This commit is contained in:
Seth 2025-04-20 03:07:04 -04:00
parent 5124e38399
commit df0627dea2

View file

@ -9,7 +9,7 @@ Bun.serve({
"/api/track/:id": async req => {
const trackId = parseInt(req.params.id)
const file = Bun.file(`downloaded/${trackId}.flac`)
/*const file = Bun.file(`downloaded/${trackId}.flac`)
if (await file.exists()) {
return new Response(await file.arrayBuffer(), {
@ -20,23 +20,23 @@ Bun.serve({
"ETag": trackId.toString(),
}
})
}
}*/
const { manifestMimeType, manifest } = await utils.fetchTrack(trackId)
const audio = await utils.tagFlac(trackId, await utils.downloadFlac(manifestMimeType, manifest))
await Bun.write(`downloaded/${trackId}.flac`, audio)
//await Bun.write(`downloaded/${trackId}.flac`, audio)
return new Response(audio, {
headers: {
"Content-Type": "audio/flac",
"Content-Disposition": `attachment; filename="${trackId}.flac"`,
//"Content-Disposition": `attachment; filename="${trackId}.flac"`,
"Cache-Control": "public, max-age=31536000",
"ETag": trackId.toString(),
}
})
},
"/api/@me/tracks": async () => {
const tracks = await utils.fetchTracks();