mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-19 16:16:45 +00:00
fix(web): preserve maximum SQL file upload limit
This commit is contained in:
@@ -130,9 +130,13 @@ pub async fn load_max_retries(State(state): State<Arc<WebState>>) -> Result<Json
|
||||
state.app.storage.load_max_retries().await.map(Json).map_err(AppError::from)
|
||||
}
|
||||
|
||||
pub async fn load_sql_file_upload_max_bytes(State(state): State<Arc<WebState>>) -> Result<Json<u32>, AppError> {
|
||||
fn sql_file_upload_max_bytes_from_mb(max_mb: u32) -> u64 {
|
||||
u64::from(max_mb).saturating_mul(1024 * 1024)
|
||||
}
|
||||
|
||||
pub async fn load_sql_file_upload_max_bytes(State(state): State<Arc<WebState>>) -> Result<Json<u64>, AppError> {
|
||||
let max_mb = state.app.storage.load_sql_file_upload_max_mb().await.map_err(AppError::from)?;
|
||||
Ok(Json(max_mb.saturating_mul(1024 * 1024)))
|
||||
Ok(Json(sql_file_upload_max_bytes_from_mb(max_mb)))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -182,7 +186,12 @@ fn decrypt_config_payload(payload: &EncryptedConfigPayload, passphrase: &str) ->
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{decrypt_config_payload, EncryptedConfigPayload};
|
||||
use super::{decrypt_config_payload, sql_file_upload_max_bytes_from_mb, EncryptedConfigPayload};
|
||||
|
||||
#[test]
|
||||
fn preserves_four_gib_sql_file_upload_limit() {
|
||||
assert_eq!(sql_file_upload_max_bytes_from_mb(4096), 4096_u64 * 1024 * 1024);
|
||||
}
|
||||
|
||||
fn exported_browser_payload() -> EncryptedConfigPayload {
|
||||
EncryptedConfigPayload {
|
||||
|
||||
Reference in New Issue
Block a user