Self-update in the background (install on close), module configs created from .dist, quiet-logging + table fixups in clean-base, backlog notes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Sonnet 5.5 committed 2026-09-30 15:36:07 +05:00
1 parent 2d0bfd0a38
commit a6ae4e78a3
15 files changed
+358 -55

No files matched your search

+6
View File
@@ -194,6 +194,12 @@ pub fn build(p: &Params, say: &dyn Fn(&str)) -> Result<()> {
if let Some((id, why)) = report.failed {
return Err(Error::Invalid(format!("Database update {id} failed: {why}")));
}
// 3b. A module script older than a table rename re-creates the old table next to the renamed one (the core then
// logs an error at every start). Fold its rows into the new table and drop it.
let both = db.query("SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA='acore_world' AND TABLE_NAME IN ('item_template_ascension_compat','item_template_coa');")?;
if both.trim() == "2" {
db.query("INSERT IGNORE INTO acore_world.item_template_coa SELECT * FROM acore_world.item_template_ascension_compat; DROP TABLE acore_world.item_template_ascension_compat;")?;
}
// 4. prove it is clean
let accounts = db.query("SELECT COUNT(*) FROM acore_auth.account;")?;
let chars = db.query("SELECT COUNT(*) FROM acore_characters.characters;")?;
+46
View File
@@ -119,6 +119,30 @@ pub struct SettingsView {
}
/// Keys whose value in the generated conf differs from the template (i.e. hand edits the launcher will reset).
/// Modules read `Core/configs/modules/<name>.conf`, but packages ship only the documented `<name>.conf.dist` (the active
/// files are the server owner's). Create every missing active file from its `.dist`, so a fresh server runs with the
/// documented defaults (for example `CoA.Enable = 1`, without which the Ascension client is dropped after login).
/// Existing files are never touched. Files the launcher writes itself are skipped. Returns the created file names.
pub fn materialize_module_configs(root: &Path) -> Result<Vec<String>> {
let dir = root.join("Core").join("configs").join("modules");
let mut created = Vec::new();
let Ok(entries) = fs::read_dir(&dir) else { return Ok(created) };
for e in entries.flatten() {
let name = e.file_name().to_string_lossy().into_owned();
let Some(stem) = name.strip_suffix(".conf.dist") else { continue };
if stem == "coa_bugreport" || stem == "mod_ascension_compat" {
continue; // written by the launcher at every start
}
let active = dir.join(format!("{stem}.conf"));
if !active.exists() {
fs::copy(e.path(), &active)?;
created.push(format!("{stem}.conf"));
}
}
created.sort();
Ok(created)
}
pub fn drift(root: &Path) -> Result<Vec<String>> {
let t = targets(root, Scope::Server)?;
let Some(generated) = &t.generated else { return Ok(Vec::new()) };
@@ -463,6 +487,28 @@ mod tests {
pairs.iter().map(|(k, v)| (k.to_string(), v.clone())).collect()
}
#[test]
fn missing_module_configs_are_created_from_their_dist_and_existing_ones_are_kept() {
let (_d, root, _m) = fixture();
let m = root.join("Core/configs/modules");
fs::create_dir_all(&m).unwrap();
fs::write(m.join("coa.conf.dist"), "CoA.Enable = 1
").unwrap();
fs::write(m.join("spellbook.conf.dist"), "Spellbook.Enable = 1
").unwrap();
fs::write(m.join("spellbook.conf"), "Spellbook.Enable = 0
").unwrap();
fs::write(m.join("coa_bugreport.conf.dist"), "x = 1
").unwrap();
assert_eq!(materialize_module_configs(&root).unwrap(), vec!["coa.conf".to_string()]);
assert_eq!(fs::read_to_string(m.join("coa.conf")).unwrap(), "CoA.Enable = 1
");
assert_eq!(fs::read_to_string(m.join("spellbook.conf")).unwrap(), "Spellbook.Enable = 0
");
assert!(!m.join("coa_bugreport.conf").exists());
assert!(materialize_module_configs(&root).unwrap().is_empty());
}
#[test]
fn schemas_and_presets_are_self_consistent() {
for scope in [Scope::Bots, Scope::Server] {
+1
View File
@@ -269,6 +269,7 @@ pub fn install_base(p: &Params, report: &dyn Fn(Step)) -> Result<Installed> {
fs::remove_dir(&dest)?; // only succeeds for an empty folder (preflight verified)
}
fs::rename(&staging_root, &dest)?;
crate::config::materialize_module_configs(&dest)?;
let mut meta = InstallMeta::new(InstallKind::New, &dest);
meta.core.commit = m.core.commit.clone();