mirror of
https://github.com/misskey-dev/media-proxy.git
synced 2025-04-29 02:47:26 +09:00
Better garbage collection?
This commit is contained in:
parent
9b1da926e1
commit
0e741f928c
@ -158,8 +158,12 @@ async function proxyHandler(request, reply) {
|
|||||||
if ('cleanup' in file) {
|
if ('cleanup' in file) {
|
||||||
if ('pipe' in image.data && typeof image.data.pipe === 'function') {
|
if ('pipe' in image.data && typeof image.data.pipe === 'function') {
|
||||||
// image.dataがstreamなら、stream終了後にcleanup
|
// image.dataがstreamなら、stream終了後にcleanup
|
||||||
image.data.on('end', file.cleanup);
|
const cleanup = () => {
|
||||||
image.data.on('close', file.cleanup);
|
file.cleanup();
|
||||||
|
image = null;
|
||||||
|
};
|
||||||
|
image.data.on('end', cleanup);
|
||||||
|
image.data.on('close', cleanup);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// image.dataがstreamでないなら直ちにcleanup
|
// image.dataがstreamでないなら直ちにcleanup
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey-media-proxy",
|
"name": "misskey-media-proxy",
|
||||||
"version": "0.0.5",
|
"version": "0.0.6",
|
||||||
"description": "The Media Proxy for Misskey",
|
"description": "The Media Proxy for Misskey",
|
||||||
"main": "built/index.js",
|
"main": "built/index.js",
|
||||||
"packageManager": "pnpm@7.26.0",
|
"packageManager": "pnpm@7.26.0",
|
||||||
|
@ -204,8 +204,12 @@ async function proxyHandler(request: FastifyRequest<{ Params: { url: string; };
|
|||||||
if ('cleanup' in file) {
|
if ('cleanup' in file) {
|
||||||
if ('pipe' in image.data && typeof image.data.pipe === 'function') {
|
if ('pipe' in image.data && typeof image.data.pipe === 'function') {
|
||||||
// image.dataがstreamなら、stream終了後にcleanup
|
// image.dataがstreamなら、stream終了後にcleanup
|
||||||
image.data.on('end', file.cleanup);
|
const cleanup = () => {
|
||||||
image.data.on('close', file.cleanup);
|
file.cleanup();
|
||||||
|
image = null;
|
||||||
|
}
|
||||||
|
image.data.on('end', cleanup);
|
||||||
|
image.data.on('close', cleanup);
|
||||||
} else {
|
} else {
|
||||||
// image.dataがstreamでないなら直ちにcleanup
|
// image.dataがstreamでないなら直ちにcleanup
|
||||||
file.cleanup();
|
file.cleanup();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user