mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 16:22:39 +10:00
failed gracefully on invalid chunk index
This commit is contained in:
@ -49,6 +49,13 @@ export default defineEventHandler(async (h3) => {
|
|||||||
|
|
||||||
const start = chunkIndex * chunkSize;
|
const start = chunkIndex * chunkSize;
|
||||||
const end = Math.min((chunkIndex + 1) * chunkSize, gameFileStats.size);
|
const end = Math.min((chunkIndex + 1) * chunkSize, gameFileStats.size);
|
||||||
|
|
||||||
|
if (start >= end)
|
||||||
|
throw createError({
|
||||||
|
statusCode: 400,
|
||||||
|
statusMessage: "Invalid chunk index",
|
||||||
|
});
|
||||||
|
|
||||||
const gameReadStream = fs.createReadStream(gameFile, { start, end });
|
const gameReadStream = fs.createReadStream(gameFile, { start, end });
|
||||||
|
|
||||||
return sendStream(h3, gameReadStream);
|
return sendStream(h3, gameReadStream);
|
||||||
|
|||||||
Reference in New Issue
Block a user