mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c0d2db368 |
No files matched your search
@@ -1,7 +0,0 @@
|
||||
---
|
||||
area: bots
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Disabling custom races for SQUID bots now excludes all nonstandard races
|
||||
---
|
||||
The standard-races preset keeps only the ten original playable races. High elves, worgen and other custom race IDs are excluded, and the displayed setting reads complete race IDs rather than matching number substrings.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Starting the server waits for update checks and identifies ongoing maintenance
|
||||
---
|
||||
Downloading an update manifest no longer blocks startup. A start waits up to 30 seconds for a check to finish; other active maintenance still blocks it safely and shows its operation, process and start time.
|
||||
@@ -55,7 +55,7 @@ pub const RACE_MPQS: &[&str] = &[
|
||||
];
|
||||
|
||||
pub const EXCLUDED_BOT_RACES_RECOMMENDED: &str =
|
||||
"9,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128";
|
||||
"19,27,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128";
|
||||
|
||||
pub const EXCLUDED_BOT_RACES_EXPERIMENTAL: &str =
|
||||
"16,19,27,32,50,52,53,65,66,67,68,69,70,71,72,74,77,80,81";
|
||||
@@ -99,8 +99,7 @@ pub fn is_bot_custom_races_allowed(root: &Path) -> Option<bool> {
|
||||
if let Ok(conf) = crate::config::parser::ConfFile::parse_bytes(&bytes) {
|
||||
if let Some(val) = conf.get("AiPlayerbot.ExcludedBotRaces") {
|
||||
let clean = val.trim().trim_matches(['"', '\'']);
|
||||
let excluded: std::collections::BTreeSet<u32> = clean.split(',').filter_map(|race| race.trim().parse().ok()).collect();
|
||||
return Some((1..=128).filter(|race| ![1, 2, 3, 4, 5, 6, 7, 8, 10, 11].contains(race)).any(|race| !excluded.contains(&race)));
|
||||
return Some(!clean.contains("33") && !clean.contains("128"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,21 +617,4 @@ mod tests {
|
||||
assert!(client_path.join("dinput8.dll").is_file());
|
||||
assert!(!client_path.join("dinput8.dll.disabled").is_file());
|
||||
}
|
||||
#[test]
|
||||
fn disabling_bot_custom_races_excludes_every_nonstandard_race() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let conf = temp.path().join("Core/configs/modules/playerbots.conf");
|
||||
fs::create_dir_all(conf.parent().unwrap()).unwrap();
|
||||
fs::write(&conf, "AiPlayerbot.ExcludedBotRaces = \"\"\n").unwrap();
|
||||
sync_bot_races_config(temp.path(), false).unwrap();
|
||||
assert_eq!(is_bot_custom_races_allowed(temp.path()), Some(false));
|
||||
let parsed = crate::config::parser::ConfFile::parse_bytes(&fs::read(conf).unwrap()).unwrap();
|
||||
let value = parsed.get("AiPlayerbot.ExcludedBotRaces").unwrap().trim_matches('"');
|
||||
let excluded: Vec<u32> = value.split(',').map(|race| race.parse().unwrap()).collect();
|
||||
for race in 1..=128 {
|
||||
assert_eq!(excluded.contains(&race), ![1, 2, 3, 4, 5, 6, 7, 8, 10, 11].contains(&race), "race {race}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -100,7 +100,7 @@ pub(crate) fn validate_update(root: &Path) -> Result<DriverOutcome> {
|
||||
fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result<DriverOutcome> {
|
||||
let root = fsx::canonicalize_lenient(root)?;
|
||||
let _update_lock = if !validating_update && matches!(verb, Verb::StartAll | Verb::StartWorld) {
|
||||
Some(crate::update::operation_lock(&crate::registry::metadata_dir_for(&root)?)?)
|
||||
Some(crate::update::operation_lock_for(&crate::registry::metadata_dir_for(&root)?, "starting server", true)?)
|
||||
} else { None };
|
||||
if !validating_update && matches!(verb, Verb::StartAll | Verb::StartWorld) {
|
||||
crate::update::ensure_recovered(&crate::registry::metadata_dir_for(&root)?)?;
|
||||
|
||||
@@ -308,9 +308,12 @@ pub fn preview(root: &Path, meta: &InstallMeta, source: &Source, trusted_key: &s
|
||||
pub fn preview_with(root: &Path, meta: &InstallMeta, source: &Source, trusted_key: &str, resolutions: &BTreeMap<String, Resolution>, access: DatabaseAccess) -> Result<Preview> {
|
||||
refuse_for_docker(root)?;
|
||||
let meta_dir = crate::registry::metadata_dir_for(root)?;
|
||||
let _lock = operation_lock(&meta_dir)?;
|
||||
ensure_recovered(&meta_dir)?;
|
||||
let observed_version = MetaDir::open(&meta_dir)?.1.core.version;
|
||||
let (m, _) = fetch_manifest(source, trusted_key)?;
|
||||
let _lock = operation_lock_for(&meta_dir, "checking updates", false)?;
|
||||
ensure_recovered(&meta_dir)?;
|
||||
let (_, current_meta) = MetaDir::open(&meta_dir)?;
|
||||
let meta = if current_meta.core.version != observed_version { ¤t_meta } else { meta };
|
||||
check_manifest(&m)?;
|
||||
reject_downgrade(meta, &m)?;
|
||||
let mut items = plan(root, meta, &m, resolutions, None)?;
|
||||
@@ -780,11 +783,26 @@ pub fn rollback(root: &Path, meta_dir: &Path, id: &str, env: &dyn Env) -> Result
|
||||
}
|
||||
|
||||
pub(crate) fn operation_lock(meta_dir: &Path) -> Result<fs::File> {
|
||||
operation_lock_for(meta_dir, "server maintenance", false)
|
||||
}
|
||||
|
||||
pub(crate) fn operation_lock_for(meta_dir: &Path, operation: &str, wait_for_check: bool) -> Result<fs::File> {
|
||||
fs::create_dir_all(meta_dir)?;
|
||||
let lock = fs::OpenOptions::new().read(true).write(true).create(true).truncate(false).open(meta_dir.join("update.lock"))?;
|
||||
if !fs4::fs_std::FileExt::try_lock_exclusive(&lock)? {
|
||||
return Err(Error::Invalid("Another update, repair or recovery is in progress.".into()));
|
||||
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(30);
|
||||
loop {
|
||||
if fs4::fs_std::FileExt::try_lock_exclusive(&lock)? { break; }
|
||||
let owner = fsx::read_json::<serde_json::Value>(&meta_dir.join("update-lock-owner.json")).ok();
|
||||
let checking = owner.as_ref().and_then(|owner| owner.get("operation")).and_then(|value| value.as_str()) == Some("checking updates");
|
||||
if wait_for_check && checking && std::time::Instant::now() < deadline {
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
continue;
|
||||
}
|
||||
let details = owner.as_ref().and_then(|owner| Some(format!(" Operation: {}; Manager process: {}; started: {}.", owner.get("operation")?.as_str()?, owner.get("pid")?.as_u64()?, owner.get("started")?.as_str()?))).unwrap_or_default();
|
||||
return Err(Error::Invalid(format!("Another update, repair or recovery is in progress.{details} Wait for that operation to finish, then retry.")));
|
||||
}
|
||||
let record = serde_json::json!({"operation": operation, "pid": std::process::id(), "started": chrono::Utc::now().to_rfc3339()});
|
||||
fsx::atomic_write_json(&meta_dir.join("update-lock-owner.json"), &record)?;
|
||||
Ok(lock)
|
||||
}
|
||||
|
||||
@@ -1358,6 +1376,25 @@ mod tests {
|
||||
w
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_waits_for_an_update_check_but_not_for_active_maintenance() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let checker = operation_lock_for(temp.path(), "checking updates", false).unwrap();
|
||||
let root = temp.path().to_path_buf();
|
||||
let release = std::thread::spawn(move || {
|
||||
std::thread::sleep(std::time::Duration::from_millis(150));
|
||||
drop(checker);
|
||||
});
|
||||
let start = operation_lock_for(&root, "starting server", true).unwrap();
|
||||
release.join().unwrap();
|
||||
let error = operation_lock(&root).unwrap_err().to_string();
|
||||
assert!(error.contains("starting server"));
|
||||
assert!(error.contains(&std::process::id().to_string()));
|
||||
drop(start);
|
||||
// Stale owner metadata is harmless once the OS lock is released.
|
||||
operation_lock(&root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_manager_realm_launcher_is_replaced_during_update() {
|
||||
let w = legacy_launcher_world(false);
|
||||
|
||||
Reference in new issue
Block a user