fix: log shouldn't be marked as "fully downloaded" when download is interrupted
Massimo Melina committed
Sep 12, 2023 at 16:40 UTC
3b90fa68cd3746e0b73b903029946224cd5263c8
1 file changed
+1
-1
src/log.ts
+1
-1
@@ -104,7 +104,7 @@ export const logMw: Koa.Middleware = async (ctx, next) => {
104
const user = getCurrentUsername(ctx)
105
const length = ctx.state.length ?? ctx.length
106
const uri = ctx.originalUrl
107
- const extra = ctx.state.includesLastByte && ctx.vfsNode && { dl: 1 }
107
+ const extra = ctx.state.includesLastByte && ctx.vfsNode && ctx.res.finished && { dl: 1 }
108
|| ctx.state.uploadPath && { ul: ctx.state.uploadPath, size: ctx.state.uploadSize }
109
|| undefined
110
events.emit(logger.name, Object.assign(_.pick(ctx, ['ip', 'method','status']), { length, user, ts: now, uri, extra }))