fix(downloads): a GIF's size warning judges the size it shows

This commit is contained in:
2026-11-11 02:19:56 +01:00
parent 27ccf253f5
commit 0b92b40db5
2 changed files with 22 additions and 5 deletions
+5 -2
View File
@@ -54,7 +54,10 @@ export type GifVerdict = "too_long" | "may_fail" | "no_preview" | "ok";
export function gifVerdict(seconds: number, est: { hi: number }): GifVerdict {
if (seconds > GIF_MAX_S + 0.0005) return "too_long";
if (est.hi > GIF_MAX_BYTES) return "may_fail";
if (est.hi > GIF_PREVIEW_MAX_BYTES) return "no_preview";
// Judged on the high end as shown (whole megabytes): "about 12–30 MB" beside "it may pass 30 MB"
// would contradict itself, and the estimate is no finer than that anyway.
const hi = Math.round(est.hi / MB) * MB;
if (hi > GIF_MAX_BYTES) return "may_fail";
if (hi > GIF_PREVIEW_MAX_BYTES) return "no_preview";
return "ok";
}