fix: clean failed document uploads and surface filesystem errors

This commit is contained in:
2026-09-06 09:15:34 +03:00
parent 43dc4feb31
commit 37b10ce09a
4 changed files with 61 additions and 7 deletions
+2 -6
View File
@@ -969,17 +969,13 @@ const server = http.createServer(async (req, res) => {
try { ofisMetni = arsivMetni(String(body.ad), buf); } catch { /* metin çıkmazsa devam */ }
if (!ikn && body.otoIkn && ofisMetni) ikn = iknCikar(ofisMetni);
}
const dosyaAdi = `${Date.now()}-${crypto.randomUUID()}`;
fs.writeFileSync(path.join(store.BELGE_DIR, dosyaAdi), buf);
const id = store.addDocument(user.email, {
const id = store.saveDocumentFile(user.email, {
ad: String(body.ad).slice(0, 200),
kategori: metadata.kategori || null,
boyut: buf.length, // GERÇEK bayt — rastgele değil
mime: body.mime || null,
dosya: dosyaAdi,
sonKullanma: metadata.sonKullanma || null,
ikn, // ihaleye bağlı belge
});
}, buf);
// Yükleme anında otomatik kalem çıkarımı — AI kullanmaz, kullanıcıdan
// tıklama beklemez. PDF'ler tarayıcıda çözüldüğü için istemci
// metni /api/kalem/cikar'a gönderir.