feat: implement caching for file info, add rate limiting, and enhance upload handling with retry logic

This commit is contained in:
MythEclipse
2026-05-21 23:31:49 +07:00
parent 10c968cf01
commit fd5eb98586
10 changed files with 557 additions and 11 deletions
+8 -5
View File
@@ -1,4 +1,5 @@
import { createReadStream, unlinkSync } from 'node:fs';
import { createReadStream } from 'node:fs';
import { unlink } from 'node:fs/promises';
import { nanoid } from 'nanoid';
import { db, files as fileSchema } from '../db';
import { findFileByHash } from '../db/files';
@@ -69,11 +70,13 @@ const performUpload = async (
updatedAt: new Date(),
};
} finally {
setTimeout(() => {
setTimeout(async () => {
try {
unlinkSync(tempPath);
} catch {}
}, 50);
await unlink(tempPath);
} catch (err) {
logger.warn('Failed to cleanup temp file', { tempPath, error: getErrorMessage(err) });
}
}, 500);
}
};