fix
This commit is contained in:
+13
-1
@@ -26,6 +26,17 @@ if (sweep.removedFiles > 0 || sweep.removedMetadata > 0) {
|
||||
const limiter = new RateLimiter(cfg.rateLimitMax, cfg.rateLimitWindowMs);
|
||||
const startedAt = Date.now();
|
||||
|
||||
const expiryTimer = setInterval(() => {
|
||||
storage
|
||||
.expireExpired()
|
||||
.then((removed) => {
|
||||
if (removed > 0) log("info", `expiry sweep removed ${removed} file(s)`);
|
||||
})
|
||||
.catch((err) => {
|
||||
log("error", `expiry sweep failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||
});
|
||||
}, 60 * 60 * 1000);
|
||||
|
||||
const STATIC_ROUTES: Record<string, { file: string; type: string }> = {
|
||||
"/": { file: "./public/index.html", type: "text/html; charset=utf-8" },
|
||||
"/index.html": { file: "./public/index.html", type: "text/html; charset=utf-8" },
|
||||
@@ -97,7 +108,7 @@ async function route(req: Request, srv: Server<undefined>): Promise<Response> {
|
||||
}
|
||||
|
||||
if (path === "/api/upload" && method === "POST") {
|
||||
return handleUpload(req, storage, cfg.maxFileSize);
|
||||
return handleUpload(req, storage, cfg.maxFileSize, cfg.fileTtlMs);
|
||||
}
|
||||
|
||||
if (path.startsWith("/api/auth/") && method === "POST") {
|
||||
@@ -145,6 +156,7 @@ log(
|
||||
for (const signal of ["SIGINT", "SIGTERM"] as const) {
|
||||
process.once(signal, () => {
|
||||
log("info", `received ${signal}, shutting down`);
|
||||
clearInterval(expiryTimer);
|
||||
server.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user