diff --git a/built/index.js b/built/index.js index 1433d3b..84b8227 100644 --- a/built/index.js +++ b/built/index.js @@ -158,8 +158,12 @@ async function proxyHandler(request, reply) { if ('cleanup' in file) { if ('pipe' in image.data && typeof image.data.pipe === 'function') { // image.dataがstreamなら、stream終了後にcleanup - image.data.on('end', file.cleanup); - image.data.on('close', file.cleanup); + const cleanup = () => { + file.cleanup(); + image = null; + }; + image.data.on('end', cleanup); + image.data.on('close', cleanup); } else { // image.dataがstreamでないなら直ちにcleanup diff --git a/package.json b/package.json index 3610791..7d0540a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey-media-proxy", - "version": "0.0.5", + "version": "0.0.6", "description": "The Media Proxy for Misskey", "main": "built/index.js", "packageManager": "pnpm@7.26.0", diff --git a/src/index.ts b/src/index.ts index 2317d31..09ef82c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -204,8 +204,12 @@ async function proxyHandler(request: FastifyRequest<{ Params: { url: string; }; if ('cleanup' in file) { if ('pipe' in image.data && typeof image.data.pipe === 'function') { // image.dataがstreamなら、stream終了後にcleanup - image.data.on('end', file.cleanup); - image.data.on('close', file.cleanup); + const cleanup = () => { + file.cleanup(); + image = null; + } + image.data.on('end', cleanup); + image.data.on('close', cleanup); } else { // image.dataがstreamでないなら直ちにcleanup file.cleanup();