STORAGE_BACKEND setting: use "local" if unspecified

the implementation now matches what is the README specifies
This commit is contained in:
Armaël Guéneau 2025-02-03 14:39:17 +01:00
parent b03d474c27
commit c64b53dfd7

View file

@ -27,19 +27,19 @@ impl Storage {
} }
pub async fn from_env() -> anyhow::Result<Self> { pub async fn from_env() -> anyhow::Result<Self> {
match env_var("STORAGE_BACKEND")?.as_ref() { match env_var("STORAGE_BACKEND").as_deref() {
"local" => { Ok("local") | Err(_) => {
let dir = match env_var("STORAGE_LOCAL_DIR") { let dir = match env_var("STORAGE_LOCAL_DIR") {
Ok(dir) => dir, Ok(dir) => dir,
Err(_) => ".".to_string(), Err(_) => ".".to_string(),
}; };
Ok(Self::from_local_dir(PathBuf::from(dir))) Ok(Self::from_local_dir(PathBuf::from(dir)))
} }
"s3" => { Ok("s3") => {
let bucket = env_var("STORAGE_S3_BUCKET")?; let bucket = env_var("STORAGE_S3_BUCKET")?;
Ok(Self::from_s3(bucket).await) Ok(Self::from_s3(bucket).await)
} }
other => { Ok(other) => {
anyhow::bail!("STORAGE_BACKEND: unexpected value {other} (expected: local/s3)") anyhow::bail!("STORAGE_BACKEND: unexpected value {other} (expected: local/s3)")
} }
} }