This commit is contained in:
Silas Brack 2026-03-07 17:14:54 +01:00
parent 71abb1ed7d
commit 689b85e6f2
3 changed files with 53 additions and 6 deletions

View file

@ -7,6 +7,8 @@ pub mod rebuild;
use std::sync::Arc;
const DEFAULT_BODY_LIMIT: usize = 256 * 1024 * 1024; // 256 MB
pub struct Args {
pub db_path: String,
pub volumes: Vec<String>,
@ -14,6 +16,15 @@ pub struct Args {
}
pub fn build_app(args: &Args) -> axum::Router {
if args.replicas > args.volumes.len() {
eprintln!(
"Error: replication factor ({}) exceeds number of volumes ({})",
args.replicas,
args.volumes.len()
);
std::process::exit(1);
}
if let Some(parent) = std::path::Path::new(&args.db_path).parent() {
std::fs::create_dir_all(parent).unwrap_or_else(|e| {
eprintln!("Failed to create database directory: {e}");
@ -37,5 +48,6 @@ pub fn build_app(args: &Args) -> axum::Router {
.delete(server::delete_key)
.head(server::head_key),
)
.layer(axum::extract::DefaultBodyLimit::max(DEFAULT_BODY_LIMIT))
.with_state(state)
}