chat attachments too
the one the sweep missed. an image or a PDF dropped into a chat went straight to its final name in the attachments directory, and the mkdir above it was redundant once Bun.write creates the parent chain anyway. no `Bun.write` left under src/servers/api that is not writeAtomic. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Officer-Session: 656f5c85-e49a-4f1f-b9f3-042a04b4d043
This commit is contained in:
@@ -2,6 +2,7 @@ import { createRouter } from '../../create-router';
|
||||
import { mkdir } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { getTmpAttachmentsDir, getAttachmentsDir } from '@@/data-path';
|
||||
import { writeAtomic } from '@@/write-atomic';
|
||||
|
||||
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5 MB
|
||||
/** PDFs never enter a prompt whole — the agent reads them from disk — so the ceiling is storage, not context. */
|
||||
@@ -49,8 +50,7 @@ uploadRouter.post('/', async (ctx) => {
|
||||
saveDir = getTmpAttachmentsDir(user.email);
|
||||
}
|
||||
|
||||
await mkdir(saveDir, { recursive: true });
|
||||
await Bun.write(join(saveDir, filename), buffer);
|
||||
await writeAtomic(join(saveDir, filename), buffer);
|
||||
|
||||
// Only an image gets a data URL. Building one for a PDF would mean carrying megabytes through the
|
||||
// browser for a preview nothing renders.
|
||||
|
||||
Reference in New Issue
Block a user