namespace all our variables
This commit is contained in:
parent
14508183ab
commit
458f791fe3
4 changed files with 17 additions and 12 deletions
|
@ -57,8 +57,8 @@ async fn main() -> std::io::Result<()> {
|
|||
start_reaper(data.clone());
|
||||
|
||||
let static_dir =
|
||||
PathBuf::from(std::env::var("STATIC_DIR").unwrap_or_else(|_| String::from("static")));
|
||||
let port = std::env::var("PORT")
|
||||
PathBuf::from(std::env::var("TRANSBEAM_STATIC_DIR").unwrap_or_else(|_| String::from("static")));
|
||||
let port = std::env::var("TRANSBEAM_PORT")
|
||||
.ok()
|
||||
.and_then(|p| p.parse::<u16>().ok())
|
||||
.unwrap_or(8080);
|
||||
|
|
10
src/store.rs
10
src/store.rs
|
@ -12,12 +12,12 @@ const STATE_FILE_NAME: &str = "files.json";
|
|||
const DEFAULT_STORAGE_DIR: &str = "storage";
|
||||
const DEFAULT_MAX_LIFETIME: u32 = 30;
|
||||
const GIGA: u64 = 1024*1024*1024;
|
||||
const DEFAULT_MAX_SINGLE_SIZE: u64 = 16*GIGA;
|
||||
const DEFAULT_MAX_TOTAL_SIZE: u64 = 64*GIGA;
|
||||
const DEFAULT_MAX_UPLOAD_SIZE: u64 = 16*GIGA;
|
||||
const DEFAULT_MAX_STORAGE_SIZE: u64 = 64*GIGA;
|
||||
|
||||
|
||||
pub(crate) fn storage_dir() -> PathBuf {
|
||||
PathBuf::from(std::env::var("STORAGE_DIR").unwrap_or_else(|_| String::from(DEFAULT_STORAGE_DIR)))
|
||||
PathBuf::from(std::env::var("TRANSBEAM_STORAGE_DIR").unwrap_or_else(|_| String::from(DEFAULT_STORAGE_DIR)))
|
||||
}
|
||||
|
||||
fn parse_env_var<T: FromStr>(var: &str, default: T) -> T {
|
||||
|
@ -29,11 +29,11 @@ pub(crate) fn max_lifetime() -> u32 {
|
|||
}
|
||||
|
||||
pub(crate) fn max_single_size() -> u64 {
|
||||
parse_env_var("TRANSBEAM_MAX_SINGLE_FILE_SIZE", DEFAULT_MAX_SINGLE_SIZE)
|
||||
parse_env_var("TRANSBEAM_MAX_UPLOAD_SIZE", DEFAULT_MAX_UPLOAD_SIZE)
|
||||
}
|
||||
|
||||
pub(crate) fn max_total_size() -> u64 {
|
||||
parse_env_var("TRANSBEAM_MAX_TOTAL_FILE_SIZE", DEFAULT_MAX_TOTAL_SIZE)
|
||||
parse_env_var("TRANSBEAM_MAX_STORAGE_SIZE", DEFAULT_MAX_STORAGE_SIZE)
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue