fix: ARMv7 32-bit compilation overflow

The constant 10 * 1024 * 1024 * 1024 (10 GB) overflows on 32-bit systems
where usize is 32-bit (max ~4GB). This caused compilation failures on
ARMv7 architecture.

Fix by using architecture-appropriate limits:
- 64-bit: 10 GB (unchanged)
- 32-bit: 1 GB (safe maximum for 32-bit usize)

Fixes #206
This commit is contained in:
BillionClaw
2026-03-17 04:39:18 +08:00
parent c9ca1f8885
commit 0cbbb6b7ac
3 changed files with 22 additions and 4 deletions
+7 -2
View File
@@ -375,9 +375,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
// Increase the default body limit to 10 GB to allow large file uploads.
// Increase the default body limit to allow large file uploads.
// Uses architecture-appropriate limit: 10 GB on 64-bit, 1 GB on 32-bit.
// Without this Axum caps Multipart bodies at 2 MB.
app = app.layer(DefaultBodyLimit::max(10 * 1024 * 1024 * 1024));
#[cfg(target_pointer_width = "64")]
const BODY_LIMIT: usize = 10 * 1024 * 1024 * 1024; // 10 GB
#[cfg(target_pointer_width = "32")]
const BODY_LIMIT: usize = 1024 * 1024 * 1024; // 1 GB
app = app.layer(DefaultBodyLimit::max(BODY_LIMIT));
// ── HTTP compression (gzip + Brotli) ─────────────────────────────────
// Negotiates the best encoding via Accept-Encoding. Skips responses