Put every tmpfs path in one place both layers can read
This commit is contained in:
@@ -57,7 +57,8 @@
|
||||
// master.conf HOST<n> / HOST<n>_NAME — host identity
|
||||
// host*.conf HOST*_SSH_KEY — used for setup-state and conf push
|
||||
// ident.cfg timeZone — Unraid's own setting, adopted for the whole PHP layer
|
||||
// VV_CACHE_DIR /tmp/vv_cache (tmpfs — RAM speed, cleared on reboot)
|
||||
// master.conf VV_CACHE_ROOT and the cache paths derived from it — shared with
|
||||
// load_config.sh, which reads the same keys from the same file
|
||||
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
// ── Timezone ──────────────────────────────────────────────────────────────────
|
||||
@@ -113,7 +114,45 @@ define('CUSTOM_SCRIPTS_DIR', $_vv_cfg['CUSTOM_SCRIPTS_DIR'] ?? '/boot/config/plu
|
||||
unset($_vv_cfg);
|
||||
|
||||
define('VV_SETUP_STATE_FILE', STATE_DIR . '/varaverk_setup.db');
|
||||
define('VV_CACHE_DIR', '/tmp/vv_cache');
|
||||
|
||||
// ── Cache roots ───────────────────────────────────────────────────────────────
|
||||
// Read from master.conf so this layer and load_config.sh resolve the same paths from the same
|
||||
// line. They used to be literals in three PHP files, restating what load_config.sh already said,
|
||||
// because PHP cannot source bash — and the two sets were kept in agreement by hand.
|
||||
//
|
||||
// Deliberately NOT via vv_conf_vars(). That parses master.conf and this host's conf in full and
|
||||
// calls vv_detect_host() on the way, and api/monitor.php's documented fast path loads this file
|
||||
// and nothing else in order to reach vv_cache_read() on a cache hit. Making every request pay a
|
||||
// full conf parse to learn a directory name would tax the exact path built to be cheap. One
|
||||
// file, seven keys, no host detection.
|
||||
//
|
||||
// The fallbacks are the pre-consolidation paths, matching load_config.sh: an installation whose
|
||||
// conf has not been through conf_upgrade yet keeps using what it is already using, rather than
|
||||
// silently relocating its caches because a variable was missing.
|
||||
$_vv_cache = [];
|
||||
foreach (@file(CONF_DIR . '/master.conf') ?: [] as $_l) {
|
||||
if (preg_match('/^\s*(VV_CACHE_ROOT|VV_CACHE_DIR|CONF_RAM_CACHE_DIR|ARR_CACHE_DIR'
|
||||
. '|AI_TOKEN_CACHE_DIR|AI_JOB_DIR|DOCKER_JOB_DIR)\s*=\s*"?([^"#\r\n]+?)"?\s*(?:#.*)?$/',
|
||||
$_l, $_m)) {
|
||||
$_vv_cache[$_m[1]] = trim($_m[2]);
|
||||
}
|
||||
}
|
||||
$_vv_root = $_vv_cache['VV_CACHE_ROOT'] ?? '/tmp/varaverk';
|
||||
// Resolves the one reference the conf actually uses. This is not a general bash expander and is
|
||||
// not trying to be — vv_conf_vars() owns that, and every value here is one level deep by design.
|
||||
$_vv_path = function (string $key, string $fallback) use ($_vv_cache, $_vv_root): string {
|
||||
$v = trim($_vv_cache[$key] ?? '');
|
||||
if ($v === '') return $fallback;
|
||||
return str_replace(['${VV_CACHE_ROOT}', '$VV_CACHE_ROOT'], $_vv_root, $v);
|
||||
};
|
||||
define('VV_CACHE_ROOT', $_vv_root);
|
||||
define('VV_CACHE_DIR', $_vv_path('VV_CACHE_DIR', '/tmp/vv_cache'));
|
||||
define('VV_CONF_RAM_CACHE_DIR', $_vv_path('CONF_RAM_CACHE_DIR', '/tmp/.cache/vv/d'));
|
||||
define('VV_ARR_CACHE_DIR', $_vv_path('ARR_CACHE_DIR', '/tmp/arr_cache'));
|
||||
define('VV_AI_TOKEN_CACHE_DIR', $_vv_path('AI_TOKEN_CACHE_DIR', '/tmp/.cache/vv/ai'));
|
||||
define('VV_AI_JOB_DIR', $_vv_path('AI_JOB_DIR', '/tmp/varaverk_ai_jobs'));
|
||||
define('VV_JOB_DIR', $_vv_path('DOCKER_JOB_DIR', '/tmp/varaverk_dk_jobs'));
|
||||
unset($_vv_cache, $_vv_root, $_vv_path, $_l, $_m);
|
||||
|
||||
// Read the setup state file into a key=>value array.
|
||||
function vv_setup_state_read(): array {
|
||||
|
||||
Reference in New Issue
Block a user