From cb34bb0892a85496b58795e1c2950306eec849bc Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Thu, 23 Jul 2026 19:54:42 +0800 Subject: [PATCH] refactor: keep one upload size predicate Remove the unused ceiling-only helper so callers cannot bypass a lowered client upload limit. The retained predicate continues to fall back to the hard ceiling when no public override is configured. --- src/lib/upload-limits.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib/upload-limits.ts b/src/lib/upload-limits.ts index ad2be726..871dc119 100644 --- a/src/lib/upload-limits.ts +++ b/src/lib/upload-limits.ts @@ -33,16 +33,19 @@ export function getClientMaxUploadMb(): number { return Math.min(parsed, MAX_UPLOAD_MB_CEILING); } -/** True when a file exceeds the effective client pre-check limit. */ +/** + * True when a file exceeds the effective client pre-check limit. + * + * This is deliberately the only size predicate exported: with the public env + * unset it falls back to the ceiling, so it subsumes the absolute + * "larger than any limit the server can accept" check. Keeping a second, + * ceiling-only predicate alongside it would let a call site silently bypass a + * lowered operator limit. + */ export function exceedsClientUploadSize(sizeInBytes: number): boolean { return sizeInBytes > getClientMaxUploadMb() * BYTES_PER_MB; } -/** True when a file is larger than any limit the server can be configured to accept. */ -export function exceedsUploadSizeCeiling(sizeInBytes: number): boolean { - return sizeInBytes > MAX_UPLOAD_MB_CEILING * BYTES_PER_MB; -} - /** * The single wording for an over-limit file, so the pre-check reads exactly the * same as the server's 413 rather than inventing a second phrasing.