Fixes
This commit is contained in:
parent
71abb1ed7d
commit
689b85e6f2
3 changed files with 53 additions and 6 deletions
12
src/lib.rs
12
src/lib.rs
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue