refactor(#2285): inline remaining 1:1 path wrappers (meta_dir, marker fns, host_conf_path)

This commit is contained in:
damocles 2026-07-10 20:30:01 +02:00 committed by mara
commit 556a213320
11 changed files with 39 additions and 72 deletions

View file

@ -7,7 +7,6 @@
use anyhow::{Context, Result};
use std::fmt::Write as _;
use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
@ -31,17 +30,6 @@ static LAST_FAILED_RELOAD: AtomicU64 = AtomicU64::new(0);
/// Minimum gap between retry attempts after a reload failure (30 s).
const RELOAD_RETRY_SECS: u64 = 30;
/// Host-side path where c0re writes the generated nginx include file.
/// The gateway container bind-mounts `/var/lib/hyperhive/gateway/`
/// (not the whole parent dir) at `/run/hive-state/` so nginx inside
/// can read it at `/run/hive-state/agents.conf`. Subdirectory scoping
/// avoids exposing the rest of `/var/lib/hyperhive/` (which may contain
/// forge tokens or other credentials) to the gateway container.
#[must_use]
pub fn host_conf_path() -> PathBuf {
crate::paths::gateway_agents_conf()
}
/// Nginx proxy headers present in every per-agent location block.
/// `$connection_upgrade` is defined in the http context by the NixOS
/// nginx module when `recommendedProxySettings = true` (which the
@ -162,7 +150,7 @@ fn render(names: &[String], frontend_dir: Option<&str>) -> String {
}
/// Atomically write the nginx include file for `names` to
/// [`host_conf_path()`]. Skips the write + reload when the rendered
/// [`crate::paths::gateway_agents_conf()`]. Skips the write + reload when the rendered
/// body matches what's already on disk (idempotent; avoids spurious
/// gateway reloads on a quiet tick).
///
@ -184,7 +172,7 @@ pub async fn write(names: &[String]) -> Result<()> {
.ok()
.filter(|s| !s.is_empty());
let body = render(names, frontend_dir.as_deref());
let path = host_conf_path();
let path = crate::paths::gateway_agents_conf();
if std::fs::read_to_string(&path).ok().as_deref() == Some(&body) {
return Ok(());
}