mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 11:25:56 +00:00
Merge Warcraft Reborn realm support into the 0.7.0 candidate
This commit is contained in:
commit
57ec6892aa
27 files changed
+322
-221
No files matched your search
@@ -381,22 +381,12 @@ pub fn create(
|
||||
let build = || -> Result<Vec<Component>> {
|
||||
let mut components = Vec::new();
|
||||
let realm = crate::realms::state(root)?;
|
||||
let mut databases: Vec<(String, &str)> = wanted_databases(kind)
|
||||
.iter()
|
||||
.map(|name| Ok((name.to_string(), realm.active.schema(name)?)))
|
||||
.collect::<Result<_>>()?;
|
||||
if realm.wildcard_created && kind != Kind::Config {
|
||||
let other = if realm.active == crate::realms::Mode::Coa {
|
||||
crate::realms::Mode::Wildcard
|
||||
} else {
|
||||
crate::realms::Mode::Coa
|
||||
};
|
||||
databases.push((
|
||||
format!("{}-characters", other.name()),
|
||||
other.schema("characters")?,
|
||||
));
|
||||
if kind == Kind::Full {
|
||||
databases.push((format!("{}-world", other.name()), other.schema("world")?));
|
||||
let mut databases: Vec<(String, &str)> = wanted_databases(kind).iter()
|
||||
.map(|name| Ok((name.to_string(), realm.active.schema(name)?))).collect::<Result<_>>()?;
|
||||
if kind != Kind::Config {
|
||||
for other in realm.modes().into_iter().filter(|m| *m != realm.active) {
|
||||
databases.push((format!("{}-characters", other.name()), other.schema("characters")?));
|
||||
if kind == Kind::Full { databases.push((format!("{}-world", other.name()), other.schema("world")?)); }
|
||||
}
|
||||
}
|
||||
if kind != Kind::Config && with_database(root, |db| db.schema_exists("acore_playerbots"))? {
|
||||
|
||||
@@ -92,6 +92,7 @@ fn sync_realm_when_closed(
|
||||
let realm = match mode {
|
||||
crate::realms::Mode::Coa => "Conquest of Azeroth",
|
||||
crate::realms::Mode::Wildcard => "Wildcard",
|
||||
crate::realms::Mode::Reborn => "Warcraft Reborn",
|
||||
};
|
||||
let new = realm_config(&old, realm);
|
||||
if new == old {
|
||||
@@ -561,6 +562,8 @@ mod tests {
|
||||
assert_eq!(fs::read_dir(backup_dir(&meta)).unwrap().count(), 1);
|
||||
assert!(sync_realm(&c, &meta, crate::realms::Mode::Wildcard).unwrap());
|
||||
assert_eq!(fs::read(c.join("WTF/Config.wtf")).unwrap(), original);
|
||||
assert!(sync_realm(&c, &meta, crate::realms::Mode::Reborn).unwrap());
|
||||
assert_eq!(fs::read(c.join("WTF/Config.wtf")).unwrap(), b"SET sound 1\r\nSET realmName \"Warcraft Reborn\"\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+19
-20
@@ -75,20 +75,11 @@ pub const SCHEMAS: [(&str, &str); 3] = [
|
||||
];
|
||||
|
||||
pub fn schema_of(kind: &str) -> Result<&'static str> {
|
||||
if kind == "playerbots" {
|
||||
return Ok("acore_playerbots");
|
||||
}
|
||||
if let Some(kind) = kind.strip_prefix("wildcard-") {
|
||||
return crate::realms::Mode::Wildcard.schema(kind);
|
||||
}
|
||||
if let Some(kind) = kind.strip_prefix("coa-") {
|
||||
return crate::realms::Mode::Coa.schema(kind);
|
||||
}
|
||||
SCHEMAS
|
||||
.iter()
|
||||
.find(|(k, _)| *k == kind)
|
||||
.map(|(_, s)| *s)
|
||||
.ok_or_else(|| Error::Invalid(format!("unknown database {kind}")))
|
||||
if kind == "playerbots" { return Ok("acore_playerbots"); }
|
||||
if let Some(kind) = kind.strip_prefix("wildcard-") { return crate::realms::Mode::Wildcard.schema(kind); }
|
||||
if let Some(kind) = kind.strip_prefix("reborn-") { return crate::realms::Mode::Reborn.schema(kind); }
|
||||
if let Some(kind) = kind.strip_prefix("coa-") { return crate::realms::Mode::Coa.schema(kind); }
|
||||
SCHEMAS.iter().find(|(k, _)| *k == kind).map(|(_, s)| *s).ok_or_else(|| Error::Invalid(format!("unknown database {kind}")))
|
||||
}
|
||||
|
||||
fn ident_ok(name: &str) -> bool {
|
||||
@@ -183,10 +174,10 @@ impl Db {
|
||||
}
|
||||
|
||||
pub fn realm_schema<'a>(&self, name: &'a str) -> &'a str {
|
||||
if self.realm == crate::realms::Mode::Wildcard {
|
||||
if self.realm != crate::realms::Mode::Coa {
|
||||
match name {
|
||||
"acore_world" => "acore_world_wildcard",
|
||||
"acore_characters" => "acore_characters_wildcard",
|
||||
"acore_world" => self.realm.schema("world").unwrap(),
|
||||
"acore_characters" => self.realm.schema("characters").unwrap(),
|
||||
_ => name,
|
||||
}
|
||||
} else {
|
||||
@@ -420,7 +411,7 @@ impl Db {
|
||||
if !ident_ok(schema) {
|
||||
return Err(Error::Invalid("bad schema name".into()));
|
||||
}
|
||||
if self.realm == crate::realms::Mode::Wildcard {
|
||||
if self.realm != crate::realms::Mode::Coa {
|
||||
let sql = std::fs::read_to_string(file)?;
|
||||
self.query(&format!(
|
||||
"SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; USE `{schema}`;\n{sql}"
|
||||
@@ -566,8 +557,8 @@ fn route_sql(sql: &str, realm: crate::realms::Mode) -> String {
|
||||
i += 1;
|
||||
}
|
||||
out.push_str(match &sql[start..i] {
|
||||
"acore_world" => "acore_world_wildcard",
|
||||
"acore_characters" => "acore_characters_wildcard",
|
||||
"acore_world" => realm.schema("world").unwrap(),
|
||||
"acore_characters" => realm.schema("characters").unwrap(),
|
||||
other => other,
|
||||
});
|
||||
} else {
|
||||
@@ -591,6 +582,14 @@ mod realm_tests {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn reborn_sql_routes_only_database_identifiers() {
|
||||
use crate::realms::Mode;
|
||||
let sql = "SELECT * FROM `acore_characters`.characters WHERE name='acore_world'; -- acore_world\nSELECT * FROM acore_world.items; SELECT * FROM acore_world_wildcard.items;";
|
||||
assert_eq!(super::route_sql(sql, Mode::Reborn), "SELECT * FROM `acore_characters_reborn`.characters WHERE name='acore_world'; -- acore_world\nSELECT * FROM acore_world_reborn.items; SELECT * FROM acore_world_wildcard.items;");
|
||||
assert_eq!(super::schema_of("reborn-characters").unwrap(), "acore_characters_reborn");
|
||||
assert_eq!(super::schema_of("reborn-auth").unwrap(), "acore_auth");
|
||||
}
|
||||
use super::*;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
|
||||
@@ -1249,14 +1249,12 @@ mod tests {
|
||||
"db;3306;acore;apppw;acore_characters"
|
||||
);
|
||||
let wild = database_env(&s, true, crate::realms::Mode::Wildcard);
|
||||
assert_eq!(
|
||||
get(&wild, "AC_WORLD_DATABASE_INFO").unwrap(),
|
||||
"db;3306;acore;apppw;acore_world_wildcard"
|
||||
);
|
||||
assert_eq!(
|
||||
get(&wild, "AC_CHARACTER_DATABASE_INFO").unwrap(),
|
||||
"db;3306;acore;apppw;acore_characters_wildcard"
|
||||
);
|
||||
assert_eq!(get(&wild, "AC_WORLD_DATABASE_INFO").unwrap(), "db;3306;acore;apppw;acore_world_wildcard");
|
||||
assert_eq!(get(&wild, "AC_CHARACTER_DATABASE_INFO").unwrap(), "db;3306;acore;apppw;acore_characters_wildcard");
|
||||
let reborn = database_env(&s, true, crate::realms::Mode::Reborn);
|
||||
assert_eq!(get(&reborn, "AC_WORLD_DATABASE_INFO").unwrap(), "db;3306;acore;apppw;acore_world_reborn");
|
||||
assert_eq!(get(&reborn, "AC_CHARACTER_DATABASE_INFO").unwrap(), "db;3306;acore;apppw;acore_characters_reborn");
|
||||
assert_eq!(get(&reborn, "AC_LOGIN_DATABASE_INFO").unwrap(), "db;3306;acore;apppw;acore_auth");
|
||||
// Accounts are shared by both realms; the auth server never sees the others.
|
||||
assert_eq!(
|
||||
get(&wild, "AC_LOGIN_DATABASE_INFO").unwrap(),
|
||||
|
||||
@@ -101,14 +101,8 @@ impl Store for Db {
|
||||
let connection = self.clone().for_realm(crate::realms::Mode::Coa);
|
||||
let world = self.realm_schema("acore_world");
|
||||
let characters = self.realm_schema("acore_characters");
|
||||
let other = if self.realm() == crate::realms::Mode::Coa {
|
||||
"acore_world_wildcard"
|
||||
} else {
|
||||
"acore_world"
|
||||
};
|
||||
let schemas: std::collections::BTreeSet<_> = [world, characters, other, AUTH_LEDGER_SCHEMA]
|
||||
.into_iter()
|
||||
.collect();
|
||||
let others: Vec<_> = [crate::realms::Mode::Coa, crate::realms::Mode::Wildcard, crate::realms::Mode::Reborn].into_iter().filter(|m| *m != self.realm()).map(|m| m.schema("world").unwrap()).collect();
|
||||
let schemas: std::collections::BTreeSet<_> = [world, characters, AUTH_LEDGER_SCHEMA].into_iter().chain(others.iter().copied()).collect();
|
||||
let catalog = connection.query(&format!("SELECT table_schema,table_name FROM information_schema.tables WHERE table_schema IN ('{}') AND table_name IN ('updates','{LEDGER_TABLE}') AND table_type='BASE TABLE';", schemas.into_iter().collect::<Vec<_>>().join("','")))?;
|
||||
let available: std::collections::BTreeSet<_> = catalog
|
||||
.lines()
|
||||
@@ -126,15 +120,7 @@ impl Store for Db {
|
||||
queries.push(format!("SELECT 'core','{kind}',{},REPEAT('0',64),'applied',1,'' FROM `{schema}`.`updates` WHERE BINARY RIGHT(name,4)='.sql'",text("LEFT(name,CHAR_LENGTH(name)-4)")));
|
||||
}
|
||||
}
|
||||
for (origin, schema, filter) in [
|
||||
("local", world, ""),
|
||||
(
|
||||
"other",
|
||||
other,
|
||||
" WHERE `db` IN ('auth','coa-auth','wildcard-auth')",
|
||||
),
|
||||
("shared", AUTH_LEDGER_SCHEMA, ""),
|
||||
] {
|
||||
for (origin, schema, filter) in [("local",world,""), ("shared",AUTH_LEDGER_SCHEMA,"")].into_iter().chain(others.iter().map(|schema| ("other", *schema, " WHERE `db` IN ('auth','coa-auth','wildcard-auth','reborn-auth')"))) {
|
||||
if available.contains(&(schema, LEDGER_TABLE)) {
|
||||
queries.push(format!("SELECT '{origin}',{},{},{},{},`baseline`,{} FROM `{schema}`.`{LEDGER_TABLE}`{filter}",text("`db`"),text("`id`"),text("`sha256`"),text("`status`"),text("COALESCE(HEX(`error`),'')")));
|
||||
}
|
||||
|
||||
@@ -173,9 +173,7 @@ fn installed_module_commits(root: &Path) -> BTreeMap<String, String> {
|
||||
|
||||
fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
let installed_commits = installed_module_commits(root);
|
||||
let wildcard = crate::realms::state(root)
|
||||
.map(|s| s.active == crate::realms::Mode::Wildcard)
|
||||
.unwrap_or(true);
|
||||
let wildcard = crate::realms::state(root).map(|s| s.active != crate::realms::Mode::Coa).unwrap_or(true);
|
||||
cat.iter()
|
||||
.cloned()
|
||||
.map(|e| {
|
||||
|
||||
@@ -62,11 +62,8 @@ pub fn set_enabled(main: &Path, enabled: bool) -> Result<realms::View> {
|
||||
));
|
||||
}
|
||||
if enabled {
|
||||
if !realms::view(main)?.supported {
|
||||
return Err(Error::Invalid(
|
||||
"Update the server to a build with Wildcard support first.".into(),
|
||||
));
|
||||
}
|
||||
if realms::state(main)?.active == Mode::Reborn { return Err(Error::Invalid("Simultaneous startup supports CoA and Wildcard. Select one of these realms first.".into())); }
|
||||
if !realms::view(main)?.supported { return Err(Error::Invalid("Update the server to a build with Wildcard support first.".into())); }
|
||||
secondary_launcher(&fs::read_to_string(main.join("Scripts/manage.py"))?)?;
|
||||
}
|
||||
let status = process::observe(main, &crate::layout::read_ports(main));
|
||||
|
||||
+176
-87
@@ -18,22 +18,15 @@ pub enum Mode {
|
||||
#[default]
|
||||
Coa,
|
||||
Wildcard,
|
||||
Reborn,
|
||||
}
|
||||
|
||||
impl Mode {
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Self::Coa => "coa",
|
||||
Self::Wildcard => "wildcard",
|
||||
}
|
||||
}
|
||||
pub fn realm_id(self) -> u32 {
|
||||
if self == Self::Coa {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
}
|
||||
match self { Self::Coa => "coa", Self::Wildcard => "wildcard", Self::Reborn => "reborn" }
|
||||
}
|
||||
pub fn realm_id(self) -> u32 { match self { Self::Coa => 1, Self::Wildcard => 2, Self::Reborn => 3 } }
|
||||
pub fn label(self) -> &'static str { match self { Self::Coa => "Conquest of Azeroth", Self::Wildcard => "Wildcard", Self::Reborn => "Warcraft Reborn" } }
|
||||
pub fn schema(self, kind: &str) -> Result<&'static str> {
|
||||
match (self, kind) {
|
||||
(_, "auth") => Ok("acore_auth"),
|
||||
@@ -41,6 +34,8 @@ impl Mode {
|
||||
(Self::Coa, "world") => Ok("acore_world"),
|
||||
(Self::Wildcard, "characters") => Ok("acore_characters_wildcard"),
|
||||
(Self::Wildcard, "world") => Ok("acore_world_wildcard"),
|
||||
(Self::Reborn, "characters") => Ok("acore_characters_reborn"),
|
||||
(Self::Reborn, "world") => Ok("acore_world_reborn"),
|
||||
_ => Err(Error::Invalid("Unknown realm database.".into())),
|
||||
}
|
||||
}
|
||||
@@ -51,6 +46,8 @@ pub struct RealmState {
|
||||
pub active: Mode,
|
||||
pub wildcard_created: bool,
|
||||
#[serde(default)]
|
||||
pub reborn_created: bool,
|
||||
#[serde(default)]
|
||||
pub simultaneous: bool,
|
||||
#[serde(default)]
|
||||
pub secondary_world_port: Option<u16>,
|
||||
@@ -58,10 +55,21 @@ pub struct RealmState {
|
||||
pub secondary_ra_port: Option<u16>,
|
||||
}
|
||||
|
||||
impl RealmState {
|
||||
pub fn created(&self, mode: Mode) -> bool { match mode { Mode::Coa => true, Mode::Wildcard => self.wildcard_created, Mode::Reborn => self.reborn_created } }
|
||||
pub fn modes(&self) -> Vec<Mode> {
|
||||
let mut modes = vec![self.active];
|
||||
modes.extend([Mode::Coa, Mode::Wildcard, Mode::Reborn].into_iter().filter(|m| *m != self.active && self.created(*m)));
|
||||
modes
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct View {
|
||||
pub active: Mode,
|
||||
pub wildcard_created: bool,
|
||||
pub reborn_created: bool,
|
||||
pub reborn_supported: bool,
|
||||
pub supported: bool,
|
||||
pub recovery_pending: bool,
|
||||
pub simultaneous: bool,
|
||||
@@ -89,23 +97,15 @@ fn world_binary(root: &Path) -> std::path::PathBuf {
|
||||
pub fn view(root: &Path) -> Result<View> {
|
||||
let s = state(root)?;
|
||||
// Inspect the binary itself; templates or an old log cannot prove installed support.
|
||||
let supported = fs::read(world_binary(root))?
|
||||
.windows(b"Wildcard synergy settings".len())
|
||||
.any(|w| w == b"Wildcard synergy settings");
|
||||
Ok(View {
|
||||
active: s.active,
|
||||
wildcard_created: s.wildcard_created,
|
||||
supported,
|
||||
recovery_pending: root.join(JOURNAL).exists(),
|
||||
simultaneous: s.simultaneous,
|
||||
secondary_world_port: s.secondary_world_port,
|
||||
secondary_running: crate::multiworld::is_running(root),
|
||||
})
|
||||
let binary = fs::read(world_binary(root))?;
|
||||
let reborn_supported = binary.windows(b"Warcraft Reborn class spells are unavailable".len()).any(|w| w == b"Warcraft Reborn class spells are unavailable");
|
||||
let supported = binary.windows(b"Wildcard synergy settings".len()).any(|w| w == b"Wildcard synergy settings");
|
||||
Ok(View { active: s.active, wildcard_created: s.wildcard_created, reborn_created: s.reborn_created, reborn_supported, supported, recovery_pending: root.join(JOURNAL).exists(), simultaneous: s.simultaneous, secondary_world_port: s.secondary_world_port, secondary_running: crate::multiworld::is_running(root) })
|
||||
}
|
||||
|
||||
pub fn guard_module(root: &Path, id: &str) -> Result<()> {
|
||||
if state(root)?.active == Mode::Wildcard && matches!(id, "companions" | "playerbots") {
|
||||
return Err(Error::Invalid("CoA companion class mechanics have not been validated for Wildcard. This module is unavailable on this realm.".into()));
|
||||
if state(root)?.active != Mode::Coa && matches!(id, "companions" | "playerbots") {
|
||||
return Err(Error::Invalid("Bot class mechanics have not been validated for this realm. This module is unavailable on this realm.".into()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -223,6 +223,24 @@ fn wildcard_configs(mut files: Files) -> Result<Files> {
|
||||
value,
|
||||
)?;
|
||||
}
|
||||
set(&mut files, "Core/configs/modules/playerbots.conf", "AiPlayerbot.Enabled", "0")?;
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
fn reborn_configs(mut files: Files) -> Result<Files> {
|
||||
for (key, value) in [
|
||||
("CoA.ClassModel", "\"wcr\""), ("CoA.GameModeMask", "0"),
|
||||
("CoA.MapClass10ToWarrior", "0"), ("CoA.RealmType", "\"live\""),
|
||||
("CoA.ClientBooleanConfigs", "\"\""),
|
||||
] { set(&mut files, "Core/configs/modules/coa.conf", key, value)?; }
|
||||
set(&mut files, "Core/configs/modules/mod-coa-challenges.conf", "CoAChallenges.GameModes.Realm", "\"\"")?;
|
||||
for path in ["Settings/worldserver.conf.template", "Core/configs/worldserver.conf"] {
|
||||
if files.contains_key(path) { set(&mut files, path, "RealmID", "3")?; }
|
||||
}
|
||||
for (key, value) in [("CoaBots.Enable", "0"), ("CoaBots.AutoLoginOnStartup", "0")] {
|
||||
set(&mut files, "Core/configs/modules/mod_coa_playerbots.conf", key, value)?;
|
||||
}
|
||||
set(&mut files, "Core/configs/modules/playerbots.conf", "AiPlayerbot.Enabled", "0")?;
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
@@ -257,17 +275,15 @@ pub fn recover(root: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn create_databases(root: &Path) -> Result<()> {
|
||||
fn create_databases(root: &Path, mode: Mode) -> Result<()> {
|
||||
crate::backup::with_database(root, |_| {
|
||||
let db = Db::from_repack(root, Account::Admin)?.for_realm(Mode::Coa);
|
||||
if db.query("SELECT COUNT(*) FROM acore_auth.realmlist WHERE id=2;")? != "0" {
|
||||
return Err(Error::Invalid(
|
||||
"Realm ID 2 is already in use. Its settings were left intact.".into(),
|
||||
));
|
||||
if db.query(&format!("SELECT COUNT(*) FROM acore_auth.realmlist WHERE id={};", mode.realm_id()))? != "0" {
|
||||
return Err(Error::Invalid(format!("Realm ID {} is already in use. Its settings were left intact.", mode.realm_id())));
|
||||
}
|
||||
for kind in ["world", "characters"] {
|
||||
let source = Mode::Coa.schema(kind)?;
|
||||
let dest = Mode::Wildcard.schema(kind)?;
|
||||
let dest = mode.schema(kind)?;
|
||||
if db.schema_exists(dest)? {
|
||||
return Err(Error::Invalid(format!("Database {dest} already exists. It was left intact; inspect it before creating a realm.")));
|
||||
}
|
||||
@@ -278,7 +294,7 @@ fn create_databases(root: &Path) -> Result<()> {
|
||||
));
|
||||
}
|
||||
}
|
||||
for (kind, tables) in crate::schema_check::WILDCARD_TABLES {
|
||||
for (kind, tables) in crate::schema_check::WILDCARD_TABLES.iter().filter(|_| mode == Mode::Wildcard) {
|
||||
let schema = crate::db::schema_of(kind)?;
|
||||
let present = db.tables(schema)?;
|
||||
let missing: Vec<_> = tables
|
||||
@@ -323,12 +339,11 @@ fn create_databases(root: &Path) -> Result<()> {
|
||||
{
|
||||
db.query(&format!("CREATE TABLE IF NOT EXISTS `{stage_world}`.coa_manager_migrations LIKE acore_world.coa_manager_migrations;"))?;
|
||||
}
|
||||
db.query("CREATE DATABASE acore_world_wildcard CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE DATABASE acore_characters_wildcard CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")?;
|
||||
let world = mode.schema("world")?;
|
||||
let characters = mode.schema("characters")?;
|
||||
db.query(&format!("CREATE DATABASE `{world}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE DATABASE `{characters}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"))?;
|
||||
let mut renames = Vec::new();
|
||||
for (stage, dest) in [
|
||||
(&stage_world, "acore_world_wildcard"),
|
||||
(&stage_chars, "acore_characters_wildcard"),
|
||||
] {
|
||||
for (stage, dest) in [(&stage_world, world), (&stage_chars, characters)] {
|
||||
for table in db.tables(stage)? {
|
||||
if !crate::db::valid_identifier(&table) {
|
||||
return Err(Error::Invalid("Unsupported table name.".into()));
|
||||
@@ -343,7 +358,7 @@ fn create_databases(root: &Path) -> Result<()> {
|
||||
{
|
||||
let host = hex::encode(host.as_bytes());
|
||||
// Host names are trusted database data, but still quote them through a hex SQL literal.
|
||||
db.query(&format!("SET @host=CONVERT(UNHEX('{host}') USING utf8mb4); SET @grant=CONCAT('GRANT ALL ON acore_world_wildcard.* TO ', QUOTE('acore'), '@', QUOTE(@host)); PREPARE realm_grant FROM @grant; EXECUTE realm_grant; DEALLOCATE PREPARE realm_grant; SET @grant=CONCAT('GRANT ALL ON acore_characters_wildcard.* TO ', QUOTE('acore'), '@', QUOTE(@host)); PREPARE realm_grant FROM @grant; EXECUTE realm_grant; DEALLOCATE PREPARE realm_grant;"))?;
|
||||
db.query(&format!("SET @host=CONVERT(UNHEX('{host}') USING utf8mb4); SET @grant=CONCAT('GRANT ALL ON {world}.* TO ', QUOTE('acore'), '@', QUOTE(@host)); PREPARE realm_grant FROM @grant; EXECUTE realm_grant; DEALLOCATE PREPARE realm_grant; SET @grant=CONCAT('GRANT ALL ON {characters}.* TO ', QUOTE('acore'), '@', QUOTE(@host)); PREPARE realm_grant FROM @grant; EXECUTE realm_grant; DEALLOCATE PREPARE realm_grant;"))?;
|
||||
}
|
||||
db.query(&format!(
|
||||
"DROP DATABASE `{stage_world}`; DROP DATABASE `{stage_chars}`;"
|
||||
@@ -368,14 +383,22 @@ pub fn select(root: &Path, mode: Mode) -> Result<View> {
|
||||
"Update the server to a build with Wildcard support first.".into(),
|
||||
));
|
||||
}
|
||||
if mode == Mode::Reborn && !view(root)?.reborn_supported {
|
||||
return Err(Error::Invalid("Update the server to a build with Warcraft Reborn support first.".into()));
|
||||
}
|
||||
if s.simultaneous && mode != s.active {
|
||||
return Err(Error::Invalid("Disable simultaneous startup before switching realms.".into()));
|
||||
}
|
||||
// Verify launcher support before creating databases or changing the selected realm.
|
||||
prepare_launcher(root)?;
|
||||
let before = configs(root)?;
|
||||
fsx::atomic_write_json(&snapshot(root, s.active), &before)?;
|
||||
if mode == Mode::Wildcard && !s.wildcard_created {
|
||||
fsx::atomic_write_json(&snapshot(root, mode), &wildcard_configs(before.clone())?)?;
|
||||
create_databases(root)?;
|
||||
s.wildcard_created = true;
|
||||
if !s.created(mode) {
|
||||
let base = if s.active == Mode::Coa { before.clone() } else { fsx::read_json(&snapshot(root, Mode::Coa))? };
|
||||
let files = match mode { Mode::Wildcard => wildcard_configs(base)?, Mode::Reborn => reborn_configs(base)?, Mode::Coa => unreachable!() };
|
||||
fsx::atomic_write_json(&snapshot(root, mode), &files)?;
|
||||
create_databases(root, mode)?;
|
||||
match mode { Mode::Wildcard => s.wildcard_created = true, Mode::Reborn => s.reborn_created = true, Mode::Coa => {} }
|
||||
fsx::atomic_write_json(&root.join(STATE), &s)?;
|
||||
}
|
||||
let target: Files = fsx::read_json(&snapshot(root, mode))?;
|
||||
@@ -457,43 +480,48 @@ const LAUNCHER_REALM_REPLACEMENTS: &[(&str, &str)] = &[
|
||||
|
||||
const LAUNCHER_REALM_INSERT: &str = "# coa-manager-realm-profiles-v1\ndef coa_realm():\n path = ROOT / 'Settings/realm-profile.json'\n return json.loads(path.read_text(encoding='utf-8')).get('active', 'coa') if path.exists() else 'coa'\n\ndef coa_realm_id():\n return 2 if coa_realm() == 'wildcard' else 1\n\ndef coa_realm_name():\n return 'Wildcard' if coa_realm() == 'wildcard' else 'Conquest of Azeroth'\n\n";
|
||||
|
||||
fn launcher_insert() -> String {
|
||||
LAUNCHER_REALM_INSERT.replace("profiles-v1", "profiles-v2")
|
||||
.replace("return 2 if", "return 3 if coa_realm() == 'reborn' else 2 if")
|
||||
.replace("return 'Wildcard' if", "return 'Warcraft Reborn' if coa_realm() == 'reborn' else 'Wildcard' if")
|
||||
}
|
||||
|
||||
fn launcher_replacements() -> Vec<(&'static str, String)> {
|
||||
LAUNCHER_REALM_REPLACEMENTS.iter().map(|(from, to)| (*from, to
|
||||
.replace("\"acore_world_wildcard\" if", "\"acore_world_reborn\" if coa_realm() == 'reborn' else \"acore_world_wildcard\" if")
|
||||
.replace("\"acore_characters_wildcard\" if", "\"acore_characters_reborn\" if coa_realm() == 'reborn' else \"acore_characters_wildcard\" if"))).collect()
|
||||
}
|
||||
|
||||
pub(crate) fn patch_launcher(source: &str) -> Result<String> {
|
||||
if source.contains("# coa-manager-realm-profiles-v2") { return Ok(source.into()); }
|
||||
if source.contains("# coa-manager-realm-profiles-v1") {
|
||||
return Ok(source.into());
|
||||
let original = unpatch_launcher(source).ok_or_else(|| Error::Invalid("Unrecognised realm launcher patch.".into()))?;
|
||||
return patch_launcher(&original);
|
||||
}
|
||||
let mut out = source.to_string();
|
||||
for &(from, to) in LAUNCHER_REALM_REPLACEMENTS {
|
||||
if !out.contains(from) {
|
||||
return Err(Error::Invalid(
|
||||
"This launcher does not support realm profiles. Update the server package first."
|
||||
.into(),
|
||||
));
|
||||
}
|
||||
out = out.replace(from, to);
|
||||
for (from, to) in launcher_replacements() {
|
||||
if !out.contains(from) { return Err(Error::Invalid("This launcher does not support realm profiles. Update the server package first.".into())); }
|
||||
out = out.replace(from, &to);
|
||||
}
|
||||
// Insert before the entry point so ROOT, json and functions are all defined when called.
|
||||
let marker = "if __name__ == \"__main__\":";
|
||||
if !out.contains(marker) {
|
||||
return Err(Error::Invalid(
|
||||
"Unrecognised server launcher entry point.".into(),
|
||||
));
|
||||
}
|
||||
Ok(out.replace(marker, &format!("{LAUNCHER_REALM_INSERT}{marker}")))
|
||||
if !out.contains(marker) { return Err(Error::Invalid("Unrecognised server launcher entry point.".into())); }
|
||||
Ok(out.replace(marker, &format!("{}{marker}", launcher_insert())))
|
||||
}
|
||||
|
||||
/// Reverse only our exact realm transformation; callers must verify the recovered original hash.
|
||||
pub(crate) fn unpatch_launcher(source: &str) -> Option<String> {
|
||||
if !source.contains(LAUNCHER_REALM_INSERT) {
|
||||
return None;
|
||||
}
|
||||
let mut original = source.replacen(LAUNCHER_REALM_INSERT, "", 1);
|
||||
for &(from, to) in LAUNCHER_REALM_REPLACEMENTS {
|
||||
original = original.replace(to, from);
|
||||
}
|
||||
patch_launcher(&original)
|
||||
.ok()
|
||||
.filter(|patched| patched == source)
|
||||
.map(|_| original)
|
||||
let (insert, replacements) = if source.contains(&launcher_insert()) {
|
||||
(launcher_insert(), launcher_replacements())
|
||||
} else if source.contains(LAUNCHER_REALM_INSERT) {
|
||||
(LAUNCHER_REALM_INSERT.into(), LAUNCHER_REALM_REPLACEMENTS.iter().map(|(a,b)| (*a, b.to_string())).collect())
|
||||
} else { return None; };
|
||||
let mut original = source.replacen(&insert, "", 1);
|
||||
for (from, to) in &replacements { original = original.replace(to, from); }
|
||||
let mut check = original.clone();
|
||||
for (from, to) in &replacements { check = check.replace(from, to); }
|
||||
check = check.replace("if __name__ == \"__main__\":", &format!("{insert}if __name__ == \"__main__\":"));
|
||||
(check == source).then_some(original)
|
||||
}
|
||||
|
||||
pub fn before_start(root: &Path) -> Result<()> {
|
||||
@@ -503,36 +531,37 @@ pub fn before_start(root: &Path) -> Result<()> {
|
||||
return Ok(());
|
||||
}
|
||||
prepare_launcher(root)?;
|
||||
if s.simultaneous && !view(root)?.supported {
|
||||
return Err(Error::Invalid(
|
||||
"The installed server build does not support simultaneous Wildcard startup.".into(),
|
||||
));
|
||||
}
|
||||
if s.simultaneous {
|
||||
fsx::atomic_write_json(&snapshot(root, s.active), &configs(root)?)?;
|
||||
}
|
||||
if s.active == Mode::Wildcard {
|
||||
if !view(root)?.supported {
|
||||
return Err(Error::Invalid(
|
||||
"The installed server build does not support Wildcard.".into(),
|
||||
));
|
||||
}
|
||||
if s.simultaneous && !view(root)?.supported { return Err(Error::Invalid("The installed server build does not support simultaneous Wildcard startup.".into())); }
|
||||
if s.simultaneous && s.active == Mode::Reborn { return Err(Error::Invalid("Simultaneous startup supports CoA and Wildcard only.".into())); }
|
||||
if s.simultaneous { fsx::atomic_write_json(&snapshot(root, s.active), &configs(root)?)?; }
|
||||
if s.active == Mode::Reborn && !view(root)?.reborn_supported { return Err(Error::Invalid("The installed server build does not support Warcraft Reborn.".into())); }
|
||||
if s.active != Mode::Coa {
|
||||
if s.active == Mode::Wildcard && !view(root)?.supported { return Err(Error::Invalid("The installed server build does not support Wildcard.".into())); }
|
||||
let path = root.join("Core/configs/modules/mod_coa_playerbots.conf");
|
||||
let mut conf = ConfFile::parse_bytes(&fs::read(&path)?)?;
|
||||
conf.set("CoaBots.Enable", "0", &[]);
|
||||
fsx::atomic_write(&path, conf.to_text().as_bytes())?;
|
||||
let path = root.join("Core/configs/modules/playerbots.conf");
|
||||
let bytes = if path.exists() { fs::read(&path)? } else { b"[worldserver]\n".to_vec() };
|
||||
let mut conf = ConfFile::parse_bytes(&bytes)?;
|
||||
conf.set("AiPlayerbot.Enabled", "0", &[]);
|
||||
fsx::atomic_write(&path, conf.to_text().as_bytes())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn setup_realmlist(root: &Path) -> Result<()> {
|
||||
let s = state(root)?;
|
||||
if !root.join(STATE).exists() || !s.wildcard_created {
|
||||
return Ok(());
|
||||
}
|
||||
let db = Db::from_repack(root, Account::Admin)?;
|
||||
if !root.join(STATE).exists() { return Ok(()); }
|
||||
let db = Db::from_repack(root, Account::Admin)?.for_realm(Mode::Coa);
|
||||
let port = layout::read_ports(root).world;
|
||||
db.query(&format!("INSERT INTO acore_auth.realmlist (id,name,address,localAddress,localSubnetMask,port,icon,flag,timezone,gamebuild) SELECT 2,'Wildcard',address,localAddress,localSubnetMask,{port},icon,2,timezone,gamebuild FROM acore_auth.realmlist WHERE id=1 ON DUPLICATE KEY UPDATE port={port}; UPDATE acore_auth.realmlist SET flag=2 WHERE id IN (1,2) AND id<>{};", s.active.realm_id()))?;
|
||||
for mode in s.modes().into_iter().filter(|m| *m != Mode::Coa) {
|
||||
let id = mode.realm_id();
|
||||
let name = mode.label();
|
||||
db.query(&format!("INSERT INTO acore_auth.realmlist (id,name,address,localAddress,localSubnetMask,port,icon,flag,timezone,gamebuild) SELECT {id},'{name}',address,localAddress,localSubnetMask,{port},icon,2,timezone,gamebuild FROM acore_auth.realmlist WHERE id=1 ON DUPLICATE KEY UPDATE port={port};"))?;
|
||||
}
|
||||
let ids = s.modes().iter().map(|m| m.realm_id().to_string()).collect::<Vec<_>>().join(",");
|
||||
db.query(&format!("UPDATE acore_auth.realmlist SET flag=2 WHERE id IN ({ids}) AND id<>{};", s.active.realm_id()))?;
|
||||
if s.simultaneous {
|
||||
let second = s
|
||||
.secondary_world_port
|
||||
@@ -551,6 +580,66 @@ pub fn setup_realmlist(root: &Path) -> Result<()> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn legacy_states_and_all_created_realms_are_enumerated_once() {
|
||||
let legacy: RealmState = serde_json::from_str(r#"{"active":"wildcard","wildcard_created":true}"#).unwrap();
|
||||
assert!(!legacy.reborn_created);
|
||||
assert_eq!(legacy.modes(), [Mode::Wildcard, Mode::Coa]);
|
||||
let all = RealmState { active: Mode::Reborn, wildcard_created: true, reborn_created: true, ..Default::default() };
|
||||
assert_eq!(all.modes(), [Mode::Reborn, Mode::Coa, Mode::Wildcard]);
|
||||
assert_eq!(serde_json::to_string(&Mode::Reborn).unwrap(), "\"reborn\"");
|
||||
assert_eq!(Mode::Reborn.realm_id(), 3);
|
||||
assert_eq!(Mode::Reborn.schema("auth").unwrap(), "acore_auth");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reborn_has_its_own_settings_and_restores_the_coa_profile() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let mut coa = Files::new();
|
||||
coa.insert("Core/configs/modules/coa.conf".into(), b"[worldserver]\nCoA.ClassModel = coa\nCoA.GameModeMask = 0\n".to_vec());
|
||||
coa.insert("Settings/worldserver.conf.template".into(), b"[worldserver]\nRealmID = 1\n".to_vec());
|
||||
coa.insert("Core/configs/modules/playerbots.conf".into(), b"[worldserver]\nAiPlayerbot.Enabled = 1\n".to_vec());
|
||||
let reborn = reborn_configs(coa.clone()).unwrap();
|
||||
let conf = ConfFile::parse_bytes(&reborn["Core/configs/modules/coa.conf"]).unwrap();
|
||||
assert_eq!(conf.get("CoA.ClassModel"), Some("\"wcr\""));
|
||||
assert_eq!(conf.get("CoA.GameModeMask"), Some("0"));
|
||||
assert_eq!(ConfFile::parse_bytes(&reborn["Settings/worldserver.conf.template"]).unwrap().get("RealmID"), Some("3"));
|
||||
assert_eq!(ConfFile::parse_bytes(&reborn["Core/configs/modules/playerbots.conf"]).unwrap().get("AiPlayerbot.Enabled"), Some("0"));
|
||||
write_configs(t.path(), &reborn).unwrap();
|
||||
write_configs(t.path(), &coa).unwrap();
|
||||
assert_eq!(configs(t.path()).unwrap(), coa);
|
||||
fsx::atomic_write_json(&t.path().join(STATE), &RealmState { active: Mode::Reborn, reborn_created: true, ..Default::default() }).unwrap();
|
||||
assert!(guard_module(t.path(), "companions").is_err());
|
||||
assert!(guard_module(t.path(), "playerbots").is_err());
|
||||
assert!(guard_module(t.path(), "content-scaling").is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reborn_support_requires_the_new_code_in_the_installed_binary() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
fsx::atomic_write(&t.path().join("Core/worldserver.exe"), b"Wildcard synergy settings").unwrap();
|
||||
assert!(!view(t.path()).unwrap().reborn_supported);
|
||||
fsx::atomic_write(&t.path().join("Core/worldserver.exe"), b"Warcraft Reborn class spells are unavailable").unwrap();
|
||||
let v = view(t.path()).unwrap();
|
||||
assert!(v.reborn_supported);
|
||||
assert!(!v.supported);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_launcher_upgrades_and_both_patch_versions_are_reversible() {
|
||||
let original = "(\"WorldDatabaseInfo\", \"acore_world\")\n(\"CharacterDatabaseInfo\", \"acore_characters\")\nSET name='AzerothCore',address=\nWHERE id=1;\nmysql(\"UPDATE acore_auth.realmlist SET flag=0\nif __name__ == \"__main__\":\n";
|
||||
let mut old = original.to_string();
|
||||
for (from, to) in LAUNCHER_REALM_REPLACEMENTS { old = old.replace(from, to); }
|
||||
old = old.replace("if __name__ == \"__main__\":", &format!("{LAUNCHER_REALM_INSERT}if __name__ == \"__main__\":"));
|
||||
assert_eq!(unpatch_launcher(&old).as_deref(), Some(original));
|
||||
let new = patch_launcher(&old).unwrap();
|
||||
assert!(new.contains("acore_world_reborn"));
|
||||
assert!(new.contains("return 3 if coa_realm() == 'reborn'"));
|
||||
assert!(new.contains("return 'Warcraft Reborn' if"));
|
||||
assert_eq!(patch_launcher(&new).unwrap(), new);
|
||||
assert_eq!(unpatch_launcher(&new).as_deref(), Some(original));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_docker_server_is_checked_for_wildcard_support_in_its_own_binary() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -38,10 +38,7 @@ pub fn check(root: &Path, dir: &Path) -> Result<Vec<DatabaseCheck>> {
|
||||
let (_, meta) = MetaDir::open(dir)?;
|
||||
let m = installed_manifest(&meta, dir)?;
|
||||
let checks = crate::backup::with_database(root, |db| {
|
||||
let mut modes = vec![crate::realms::Mode::Coa];
|
||||
if crate::realms::state(root)?.wildcard_created {
|
||||
modes.push(crate::realms::Mode::Wildcard);
|
||||
}
|
||||
let modes = crate::realms::state(root)?.modes();
|
||||
let mut checks = Vec::new();
|
||||
for mode in modes {
|
||||
let db = db.clone().for_realm(mode);
|
||||
|
||||
@@ -1528,14 +1528,7 @@ impl RepackEnv<'_> {
|
||||
}
|
||||
let count = |db: &crate::db::Db| -> Result<usize> {
|
||||
let realms = crate::realms::state(self.root)?;
|
||||
let mut modes = vec![realms.active];
|
||||
if realms.wildcard_created {
|
||||
modes.push(if realms.active == crate::realms::Mode::Coa {
|
||||
crate::realms::Mode::Wildcard
|
||||
} else {
|
||||
crate::realms::Mode::Coa
|
||||
});
|
||||
}
|
||||
let modes = realms.modes();
|
||||
let mut count = 0;
|
||||
for (index, mode) in modes.into_iter().enumerate() {
|
||||
let list: Vec<_> = manifest
|
||||
@@ -1675,10 +1668,7 @@ impl Env for RepackEnv<'_> {
|
||||
}
|
||||
}
|
||||
crate::backup::with_database(self.root, |db| {
|
||||
let mut modes = vec![crate::realms::Mode::Coa];
|
||||
if crate::realms::state(self.root)?.wildcard_created {
|
||||
modes.push(crate::realms::Mode::Wildcard);
|
||||
}
|
||||
let modes = crate::realms::state(self.root)?.modes();
|
||||
for mode in modes {
|
||||
if let Some(problem) = crate::schema_check::check_with_report(
|
||||
&db.clone().for_realm(mode),
|
||||
@@ -1811,10 +1801,7 @@ impl RepackEnv<'_> {
|
||||
use crate::process::{observe, ServiceState};
|
||||
let identities = crate::backup::with_database(self.root, |db| {
|
||||
if check_schema {
|
||||
let mut modes = vec![crate::realms::Mode::Coa];
|
||||
if crate::realms::state(self.root)?.wildcard_created {
|
||||
modes.push(crate::realms::Mode::Wildcard);
|
||||
}
|
||||
let modes = crate::realms::state(self.root)?.modes();
|
||||
for mode in modes {
|
||||
if let Some(p) = crate::schema_check::check_with_report(
|
||||
&db.clone().for_realm(mode),
|
||||
@@ -1905,14 +1892,7 @@ fn migrate_databases(
|
||||
snapshot: &dyn Fn() -> Result<String>,
|
||||
) -> Result<ApplyReport> {
|
||||
let realms = crate::realms::state(root)?;
|
||||
let mut modes = vec![realms.active];
|
||||
if realms.wildcard_created {
|
||||
modes.push(if realms.active == crate::realms::Mode::Coa {
|
||||
crate::realms::Mode::Wildcard
|
||||
} else {
|
||||
crate::realms::Mode::Coa
|
||||
});
|
||||
}
|
||||
let modes = realms.modes();
|
||||
// Reject a broken history in either realm before changing the first one.
|
||||
for (index, mode) in modes.iter().enumerate() {
|
||||
let list: Vec<_> = manifest
|
||||
@@ -1981,11 +1961,8 @@ fn database_identities(
|
||||
let mut identities = BTreeMap::new();
|
||||
for (schema, table, columns) in [
|
||||
("acore_characters", "characters", "guid,account,HEX(name)"),
|
||||
(
|
||||
"acore_characters_wildcard",
|
||||
"characters",
|
||||
"guid,account,HEX(name)",
|
||||
),
|
||||
("acore_characters_wildcard", "characters", "guid,account,HEX(name)"),
|
||||
("acore_characters_reborn", "characters", "guid,account,HEX(name)"),
|
||||
("acore_auth", "account", "id,HEX(username)"),
|
||||
] {
|
||||
if !db.schema_exists(schema)? || !db.tables(schema)?.iter().any(|name| name == table) {
|
||||
|
||||
@@ -10,6 +10,7 @@ const FILES: &[&str] = &[
|
||||
".realms/secondary/Settings/repack.json", ".realms/secondary/Settings/realm-profile.json",
|
||||
".realms/secondary/Settings/worldserver.conf.template", ".realms/secondary/Settings/authserver.conf.template",
|
||||
".realms/secondary/Core/configs/worldserver.conf", ".realms/secondary/Core/configs/authserver.conf",
|
||||
"Settings/realm-profiles/reborn.json",
|
||||
];
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@@ -94,6 +95,7 @@ mod tests {
|
||||
#[test]
|
||||
fn interrupted_validation_restores_original_bytes_and_absent_files() {
|
||||
let (_dir, root, meta) = fixture();
|
||||
fsx::atomic_write(&root.join("Settings/realm-profiles/reborn.json"), b"saved reborn profile").unwrap();
|
||||
let original: Vec<_> = FILES.iter().map(|p| fs::read(root.join(p)).ok()).collect();
|
||||
begin(&root, &meta).unwrap();
|
||||
assert!(crate::update::ensure_recovered(&meta).is_err());
|
||||
@@ -106,6 +108,7 @@ mod tests {
|
||||
let config = ConfFile::parse_bytes(&fs::read(root.join(FILES[2])).unwrap()).unwrap();
|
||||
assert_eq!(config.get("BindIP"), Some("\"127.0.0.1\""));
|
||||
fsx::atomic_write(&root.join(FILES[4]), b"rendered temporary configuration").unwrap();
|
||||
fsx::atomic_write(&root.join("Settings/realm-profiles/reborn.json"), b"temporary reborn profile").unwrap();
|
||||
restore(&root, &meta).unwrap();
|
||||
for (rel, bytes) in FILES.iter().zip(original) { assert_eq!(fs::read(root.join(rel)).ok(), bytes); }
|
||||
assert!(!pending(&meta));
|
||||
@@ -141,7 +144,11 @@ pub(crate) fn restore(root: &Path, meta: &Path) -> Result<()> {
|
||||
if !pending(meta) { return Ok(()); }
|
||||
let journal = meta.join("validation-configs.json");
|
||||
let saved: BTreeMap<String, Saved> = fsx::read_json(&journal)?;
|
||||
if saved.len() != FILES.len() || FILES.iter().any(|rel| !saved.contains_key(*rel)) {
|
||||
// Previous managers could journal only the first two profiles. Recover those
|
||||
// journals too, while continuing to reject missing or unknown legacy entries.
|
||||
let legacy = saved.len() == FILES.len() - 1 && !saved.contains_key("Settings/realm-profiles/reborn.json");
|
||||
let required = if legacy { &FILES[..FILES.len() - 1] } else { FILES };
|
||||
if saved.len() != required.len() || required.iter().any(|rel| !saved.contains_key(*rel)) {
|
||||
return Err(Error::Invalid("Isolated validation configuration journal is incomplete.".into()));
|
||||
}
|
||||
for (rel, file) in &saved {
|
||||
|
||||
Reference in new issue
Block a user