This commit is contained in:
naskya 2024-07-01 10:52:16 +09:00
parent 97a7db1373
commit 5dd9697fe3
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -340,14 +340,14 @@ fn create_new_server_config(
if let Some(max_size) = default_yml.get("maxFileSize") { if let Some(max_size) = default_yml.get("maxFileSize") {
let max_size_mb = max_size let max_size_mb = max_size
.as_i64() .as_i64()
.ok_or(Error::InvalidConfig("maxFileSize is not an integer"))? .ok_or(Error::InvalidConfig("`maxFileSize` is not an integer"))?
/ 1_000_000; / 1_000_000;
file.max_size = Some(max_size_mb as u64); file.max_size = Some(max_size_mb as u64);
} }
if let Some(proxy_remote_files) = default_yml.get("proxyRemoteFiles") { if let Some(proxy_remote_files) = default_yml.get("proxyRemoteFiles") {
let proxy_remote_files = proxy_remote_files let proxy_remote_files = proxy_remote_files.as_bool().ok_or(Error::InvalidConfig(
.as_bool() "`proxyRemoteFiles` is not a boolean value",
.ok_or(Error::InvalidConfig("proxyRemoteFiles is not bool"))?; ))?;
file.proxy_remote_file = Some(proxy_remote_files); file.proxy_remote_file = Some(proxy_remote_files);
} }
if meta.cache_remote_files { if meta.cache_remote_files {
@ -368,7 +368,7 @@ fn create_new_server_config(
Some(hosts) => Some( Some(hosts) => Some(
hosts hosts
.as_vec() .as_vec()
.ok_or(Error::InvalidConfig("proxyBypassHosts is not an array"))? .ok_or(Error::InvalidConfig("`proxyBypassHosts` is not an array"))?
.iter() .iter()
.map(|host| { .map(|host| {
host.as_str() host.as_str()
@ -387,7 +387,7 @@ fn create_new_server_config(
enabled: true, enabled: true,
url: url url: url
.as_str() .as_str()
.ok_or(Error::InvalidConfig("proxyUrl is not a string"))? .ok_or(Error::InvalidConfig("`proxyUrl` is not a string"))?
.to_string(), .to_string(),
bypass_hosts: http_proxy_bypass_hosts, bypass_hosts: http_proxy_bypass_hosts,
}), }),