mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 08:12:40 +10:00
feat: content length header for chunk downloads
This commit is contained in:
@ -33,7 +33,7 @@ export default defineEventHandler(async (h3) => {
|
|||||||
const versionDir = path.join(
|
const versionDir = path.join(
|
||||||
libraryManager.fetchLibraryPath(),
|
libraryManager.fetchLibraryPath(),
|
||||||
game.libraryBasePath,
|
game.libraryBasePath,
|
||||||
versionName,
|
versionName
|
||||||
);
|
);
|
||||||
if (!fs.existsSync(versionDir))
|
if (!fs.existsSync(versionDir))
|
||||||
throw createError({
|
throw createError({
|
||||||
@ -49,6 +49,8 @@ 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);
|
||||||
|
const currentChunkSize = end - start;
|
||||||
|
setHeader(h3, "Content-Length", currentChunkSize);
|
||||||
|
|
||||||
if (start >= end)
|
if (start >= end)
|
||||||
throw createError({
|
throw createError({
|
||||||
|
|||||||
Reference in New Issue
Block a user