1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-08-06 17:40:59 +00:00

feat(media): deep hashed directory structure

This commit is contained in:
Matthias Ahouansou 2025-03-23 17:23:57 +00:00
parent 66a14ac802
commit 19d0ea408c
No known key found for this signature in database
5 changed files with 173 additions and 35 deletions

View file

@ -47,33 +47,53 @@ static GLOBAL: Jemalloc = Jemalloc;
static SUB_TABLES: [&str; 3] = ["well_known", "tls", "media"]; // Not doing `proxy` cause setting that with env vars would be a pain
// Yeah, I know it's terrible, but since it seems the container users dont want syntax like A[B][C]="...",
// this is what we have to deal with. Also see: https://github.com/SergioBenitez/Figment/issues/12#issuecomment-801449465
static SUB_SUB_TABLES: [&str; 1] = ["directory_structure"];
#[tokio::main]
async fn main() {
clap::parse();
// Initialize config
let raw_config =
Figment::new()
.merge(
Toml::file(Env::var("CONDUIT_CONFIG").expect(
let raw_config = Figment::new()
.merge(
Toml::file(
Env::var("CONDUIT_CONFIG").expect(
"The CONDUIT_CONFIG env var needs to be set. Example: /etc/conduit.toml",
))
.nested(),
),
)
.merge(Env::prefixed("CONDUIT_").global().map(|k| {
let mut key: Uncased = k.into();
.nested(),
)
.merge(Env::prefixed("CONDUIT_").global().map(|k| {
let mut key: Uncased = k.into();
for table in SUB_TABLES {
if k.starts_with(&(table.to_owned() + "_")) {
key = Uncased::from(
table.to_owned() + "." + k[table.len() + 1..k.len()].as_str(),
);
break;
'outer: for table in SUB_TABLES {
if k.starts_with(&(table.to_owned() + "_")) {
for sub_table in SUB_SUB_TABLES {
if k.starts_with(&(table.to_owned() + "_" + sub_table + "_")) {
key = Uncased::from(
table.to_owned()
+ "."
+ sub_table
+ "."
+ k[table.len() + 1 + sub_table.len() + 1..k.len()].as_str(),
);
break 'outer;
}
}
}
key
}));
key = Uncased::from(
table.to_owned() + "." + k[table.len() + 1..k.len()].as_str(),
);
break;
}
}
key
}));
let config = match raw_config.extract::<Config>() {
Ok(s) => s,