refactor(runtime-bundle): share provider section order

This commit is contained in:
Tunglies
2026-12-03 20:56:45 +08:00
parent 473452c57e
commit 4fa9983576
+14 -18
View File
@@ -9,6 +9,8 @@ use std::collections::{BTreeMap, HashSet};
use std::path::{Component, Path, PathBuf, Prefix};
use tristr::TriStr;
const PROVIDER_SECTIONS: [&str; 2] = ["proxy-providers", "rule-providers"];
pub const GEO_ASSETS: &[&str] = &[
"Country.mmdb",
"ASN.mmdb",
@@ -59,7 +61,7 @@ pub fn remote_providers_of(config: &Mapping, config_root: &Path) -> Result<Vec<R
let config_root = std::fs::canonicalize(config_root)?;
let mut destinations = HashSet::new();
let mut remote_providers = Vec::new();
for section in ["proxy-providers", "rule-providers"] {
for section in PROVIDER_SECTIONS {
let Some(providers) = config.get(section).and_then(Value::as_mapping) else {
continue;
};
@@ -88,7 +90,7 @@ pub fn resolve_provider_path_conflicts(config: &mut Mapping, config_root: &Path)
let config_root = std::fs::canonicalize(config_root)?;
let mut paths = BTreeMap::<TriStr, ProviderPathOwners>::new();
let mut reserved: HashSet<TriStr> = GEO_ASSETS.iter().copied().map(TriStr::from).collect();
for section in ["proxy-providers", "rule-providers"] {
for section in PROVIDER_SECTIONS {
let Some(providers) = config.get(section).and_then(Value::as_mapping) else {
continue;
};
@@ -172,22 +174,16 @@ fn collect_runtime_parts(mut config: Value, config_root: &Path) -> Result<Runtim
let mut destinations = HashSet::new();
let mut remote_providers = Vec::new();
collect_provider_assets(
&mut config,
"proxy-providers",
&config_root,
&mut destinations,
&mut assets,
&mut remote_providers,
)?;
collect_provider_assets(
&mut config,
"rule-providers",
&config_root,
&mut destinations,
&mut assets,
&mut remote_providers,
)?;
for section in PROVIDER_SECTIONS {
collect_provider_assets(
&mut config,
section,
&config_root,
&mut destinations,
&mut assets,
&mut remote_providers,
)?;
}
collect_ssh_private_keys(&mut config, &config_root, &mut destinations, &mut assets);
for filename in GEO_ASSETS {
let source = config_root.join(filename);