fix extension

This commit is contained in:
CherretGit
2026-03-16 17:45:35 +07:00
parent 6c979bdeea
commit c050ee22b8
2 changed files with 8 additions and 7 deletions

View File

@@ -111,11 +111,11 @@ pub async fn start_service() -> anyhow::Result<()> {
.into_iter()
.map(|m| (m.id().clone(), m))
.collect();
let strat_modified = prepare_manifests(&start, &regex_hostlist, &hostlists, &tmp_dir)?;
let strat_modified = prepare_manifests(&strat_modified, &regex_hostlist_exclude, &hostlists_exclude, &tmp_dir)?;
let strat_modified = prepare_manifests(&strat_modified, &regex_ipset, &ipset, &tmp_dir)?;
let strat_modified = prepare_manifests(&strat_modified, &regex_ipset_exclude, &ipset_exclude, &tmp_dir)?;
let strat_modified = prepare_manifests(&strat_modified, &regex_bindir, &bins, &tmp_dir)?;
let strat_modified = prepare_manifests(&start, &regex_hostlist, &hostlists, &tmp_dir, "txt")?;
let strat_modified = prepare_manifests(&strat_modified, &regex_hostlist_exclude, &hostlists_exclude, &tmp_dir, "txt")?;
let strat_modified = prepare_manifests(&strat_modified, &regex_ipset, &ipset, &tmp_dir, "txt")?;
let strat_modified = prepare_manifests(&strat_modified, &regex_ipset_exclude, &ipset_exclude, &tmp_dir, "txt")?;
let strat_modified = prepare_manifests(&strat_modified, &regex_bindir, &bins, &tmp_dir, "bin")?;
let strat_modified = regex_hostlists.replace_all(&strat_modified, &hosts);
let strat_modified = regex_ipsets.replace_all(&strat_modified, &ipsets);
let strat_modified =

View File

@@ -3,7 +3,7 @@ use regex::Regex;
use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
pub fn prepare_manifests(input: &str, regex: &Regex, manifests: &HashMap<String, Manifest>, tmp_dir: &Path) -> anyhow::Result<String> {
pub fn prepare_manifests(input: &str, regex: &Regex, manifests: &HashMap<String, Manifest>, tmp_dir: &Path, ext: &str) -> anyhow::Result<String> {
let required: HashSet<String> = regex.captures_iter(input).map(|c| c[1].to_string()).collect();
let mut paths: HashMap<String, PathBuf> = HashMap::new();
for id in &required {
@@ -11,7 +11,8 @@ pub fn prepare_manifests(input: &str, regex: &Regex, manifests: &HashMap<String,
.get(id)
.ok_or_else(|| anyhow::anyhow!("Manifest not found: {}", id))?;
let path = Path::new(manifest.file());
let dst = tmp_dir.join(format!("{}.txt", id));
let mut dst = tmp_dir.join(id);
dst.set_extension(ext);
std::fs::copy(path, &dst)?;
paths.insert(id.clone(), dst);
}