Compare commits

..
Author SHA1 Message Date
Дмитрий 1a71f18def fix(client): create missing patch directories before publishing 2026-10-13 06:20:23 +05:00
Дмитрий 7d7bc530ec fix(client): preserve originals and verify race patch lifecycle 2026-10-13 06:14:32 +05:00
Corfirean d86a1676fe Merge pull request #78 from Corfirean/fix/navigation-update-journal
Prevent quadratic recovery journal writes during large updates
2026-10-12 03:54:42 +05:00
Дмитрий 53a05820c8 Prepare recovery once for bulk updates and release Manager 0.6.15 2026-10-12 03:47:24 +05:00
Дмитрий 58c976a388 Prepare Manager version 0.6.14 2026-10-12 02:03:36 +05:00
Corfirean 35c4d03bdc Merge pull request #77 from Corfirean/fix/rehearsal-copy-prefix
Normalize rehearsal roots to avoid Windows path prefix errors
2026-10-12 02:01:55 +05:00
Дмитрий c45f962d02 Normalize rehearsal roots to avoid prefix errors on Windows 2026-10-12 01:03:35 +05:00
Corfirean f52bd8ba5f Merge pull request #75 from Corfirean/fix/upgrade-fixture-paths
Use absolute paths throughout Manager upgrade qualification
2026-10-11 22:03:49 +05:00
Дмитрий 247159e56c Normalize all upgrade qualification paths before update transactions 2026-10-11 22:03:09 +05:00
Corfirean cdd5be2365 Merge pull request #74 from Corfirean/fix/startup-fixture-paths
Fix relative startup fixture paths selecting old server binaries
2026-10-11 21:50:13 +05:00
Дмитрий 7e170744bf Exercise an explicitly relative fixture path in regression 2026-10-11 21:50:09 +05:00
Дмитрий 10daa9b74d Resolve startup fixture roots before copying candidate files 2026-10-11 21:49:44 +05:00
Corfirean ed7bf7262b Merge pull request #71 from Corfirean/fix/player-race-patches
Add custom race patch installation for remote players
2026-10-11 15:37:54 +05:00
Дмитрий 7c866b116d feat(client): install custom race patches in player mode 2026-10-11 15:37:44 +05:00
Corfirean cfea54e203 Merge pull request #68 from Corfirean/release/0.6.13
Keep the next Manager release at 0.6.13
2026-10-11 01:39:57 +05:00
Дмитрий 57aa97da8a Revert "Prepare Manager version 0.7.0"
This reverts commit 6fd2130fc4.
2026-10-11 01:39:35 +05:00
Corfirean b9f89a4ae4 Merge pull request #67 from Corfirean/release/0.7.0
Prepare Manager 0.7.0
2026-10-11 01:38:56 +05:00
24 changed files with 603 additions and 157 deletions

No files matched your search

Generated
+3 -3
View File
@@ -491,7 +491,7 @@ dependencies = [
[[package]] [[package]]
name = "coa-core" name = "coa-core"
version = "0.7.0" version = "0.6.15"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"chrono", "chrono",
@@ -520,7 +520,7 @@ dependencies = [
[[package]] [[package]]
name = "coa-release" name = "coa-release"
version = "0.7.0" version = "0.6.15"
dependencies = [ dependencies = [
"chrono", "chrono",
"coa-core", "coa-core",
@@ -529,7 +529,7 @@ dependencies = [
[[package]] [[package]]
name = "coa-server-manager" name = "coa-server-manager"
version = "0.7.0" version = "0.6.15"
dependencies = [ dependencies = [
"coa-core", "coa-core",
"serde", "serde",
+1 -1
View File
@@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/coa-core", "crates/coa-release", "src-tauri"] members = ["crates/coa-core", "crates/coa-release", "src-tauri"]
[workspace.package] [workspace.package]
version = "0.7.0" version = "0.6.15"
edition = "2021" edition = "2021"
license = "AGPL-3.0-only" license = "AGPL-3.0-only"
@@ -0,0 +1,7 @@
---
area: manager
type: added
audience: players
title: Players can install custom race patches when connecting to a friend
---
Install the custom race client patch directly from the Game client section without hosting a server.
@@ -0,0 +1,7 @@
---
area: manager
type: fixed
audience: admins
title: Large server updates no longer repeatedly rewrite the recovery journal
---
Updates containing rebuilt navigation data now prepare all recovery copies before replacing files. Interrupted updates remain recoverable without rewriting the full journal for every file.
@@ -0,0 +1,7 @@
---
area: manager
type: fixed
audience: admins
title: Normalize rehearsal server roots to prevent Windows path prefix errors
---
Server update rehearsals now canonicalize the installation root before collecting files, resolving a "prefix not found" error during rehearsal preparation on Windows.
@@ -0,0 +1,7 @@
---
area: manager
type: fixed
audience: admins
title: Client race patches can be repaired and removed while preserving original files
---
Every overwritten client file gets an original backup. Switching preserves newer launcher files; checksums detect missing or replaced assets. Repair and removal are always available, with rollback if a file operation fails.
+366 -128
View File
@@ -152,101 +152,210 @@ pub struct ClientPatchStatus {
pub client_path: Option<String>, pub client_path: Option<String>,
} }
/// Inspect the client folder and determine the state of custom races patches. #[derive(Clone, Serialize, Deserialize)]
pub fn client_patch_status(client_path: &Path) -> ClientPatchStatus { struct PatchFile {
let data_dir = client_path.join("Data"); path: String,
let mut enabled_count = 0; sha256: String,
let mut disabled_count = 0;
for mpq in RACE_MPQS {
if data_dir.join(format!("{mpq}.disabled")).is_file() {
disabled_count += 1;
} else if data_dir.join(mpq).is_file() {
enabled_count += 1;
}
}
let has_root = client_path.join("EsteriaAppearance.dll").is_file()
|| client_path.join("dinput8.dll").is_file()
|| client_path.join("dinput8.dll.disabled").is_file();
let total = RACE_MPQS.len();
let current_version = fs::read_to_string(client_path.join(MANIFEST_FILENAME)).ok()
.is_some_and(|manifest| manifest.lines().any(|line| line == format!("# CoA Custom {CLIENT_VERSION}")));
let state = if enabled_count == total && current_version && client_path.join("dinput8.dll").is_file() {
ClientPatchState::Enabled
} else if disabled_count == total && current_version && client_path.join("dinput8.dll.disabled").is_file() {
ClientPatchState::Disabled
} else if (enabled_count + disabled_count) > 0 {
ClientPatchState::PartiallyInstalled
} else {
ClientPatchState::NotInstalled
};
ClientPatchStatus {
state,
installed_mpqs: enabled_count + disabled_count,
total_mpqs: total,
has_root_files: has_root,
client_path: Some(client_path.to_string_lossy().into_owned()),
}
} }
/// Enable or disable client patches by renaming MPQs and `dinput8.dll` with `.disabled`. fn patch_files(client: &Path) -> Result<Vec<PatchFile>> {
pub fn set_client_patch_enabled(client_path: &Path, enabled: bool) -> Result<()> { let bundled: std::collections::BTreeMap<String, String> = serde_json::from_str(include_str!("custom_races_hashes.json"))?;
if !client_path.is_dir() { let manifest = fs::read_to_string(client.join(MANIFEST_FILENAME)).unwrap_or_default();
return Err(Error::Invalid("Game client directory not found.".into())); let mut files = std::collections::BTreeMap::new();
} for line in manifest.lines() {
let path = if let Some(name) = line.strip_prefix("MPQ:") {
if crate::client::is_running(client_path) { if name.contains(['/', '\\']) { return Err(Error::Invalid("Invalid custom races patch manifest.".into())); }
return Err(Error::Invalid("Close the game before changing custom races patches.".into())); Some(format!("Data/{name}"))
} } else if let Some(name) = line.strip_prefix("ROOT:") {
if !client_path.join(MANIFEST_FILENAME).is_file() if name.contains(['/', '\\']) { return Err(Error::Invalid("Invalid custom races patch manifest.".into())); }
&& !RACE_MPQS.iter().skip(1).any(|name| client_path.join("Data").join(name).is_file() Some(name.to_string())
|| client_path.join("Data").join(format!("{name}.disabled")).is_file()) { } else { None };
return Ok(()); if let Some(path) = path {
} fsx::safe_join(client, &path)?;
let mut paths: Vec<PathBuf> = RACE_MPQS.iter().map(|name| client_path.join("Data").join(name)).collect(); files.insert(path.clone(), bundled.get(&path).cloned().unwrap_or_default());
if let Ok(manifest) = fs::read_to_string(client_path.join(MANIFEST_FILENAME)) {
for line in manifest.lines() {
if let Some(name) = line.strip_prefix("MPQ:") {
if name.contains(['/', '\\']) || !name.to_ascii_lowercase().ends_with(".mpq") {
return Err(Error::Invalid("Invalid custom races patch manifest.".into()));
}
paths.push(fsx::safe_join(&client_path.join("Data"), name)?);
}
} }
} }
paths.sort(); if files.is_empty() { files = bundled; }
paths.dedup(); for line in manifest.lines().filter_map(|line| line.strip_prefix("SHA256:")) {
paths.push(client_path.join("dinput8.dll")); let (hash, path) = line.split_once(':').ok_or_else(|| Error::Invalid("Invalid custom races checksum.".into()))?;
paths.push(client_path.join("Ascension.exe")); if hash.len() != 64 || !hash.bytes().all(|b| b.is_ascii_hexdigit()) || !files.contains_key(path) {
for active in paths { return Err(Error::Invalid("Invalid custom races checksum.".into()));
let disabled = active.with_extension(format!("{}.disabled", active.extension().unwrap_or_default().to_string_lossy())); }
let original = active.with_extension(format!("{}.original", active.extension().unwrap_or_default().to_string_lossy())); files.insert(path.into(), hash.into());
if enabled && disabled.is_file() { }
if active.is_file() { Ok(files.into_iter().map(|(path, sha256)| PatchFile { path, sha256 }).collect())
if !original.is_file() { }
return Err(Error::Invalid(format!("Cannot replace existing {} without an original backup.", active.display())));
} fn suffix(path: &Path, extension: &str) -> PathBuf {
fs::remove_file(&active)?; path.with_file_name(format!("{}.{extension}", path.file_name().unwrap_or_default().to_string_lossy()))
} }
fs::rename(&disabled, &active)?;
} else if !enabled && active.is_file() && !disabled.is_file() { fn matches_patch(path: &Path, file: &PatchFile) -> bool {
if active.file_name().is_some_and(|name| name == "Ascension.exe") && !original.is_file() { path.is_file() && fsx::sha256_file(path).is_ok_and(|hash| hash == file.sha256)
continue; }
}
fs::rename(&active, &disabled)?; /// Only complete, verified payloads are reported as enabled or disabled.
if original.is_file() { pub fn client_patch_status(client_path: &Path) -> ClientPatchStatus {
fs::copy(&original, &active)?; let data = client_path.join("Data");
} let installed_mpqs = RACE_MPQS.iter().filter(|name| data.join(name).is_file() || suffix(&data.join(name), "disabled").is_file()).count();
let has_root_files = client_path.join("EsteriaAppearance.dll").is_file() || client_path.join("dinput8.dll").is_file() || client_path.join("dinput8.dll.disabled").is_file();
let manifest = fs::read_to_string(client_path.join(MANIFEST_FILENAME)).unwrap_or_default();
let current = manifest.lines().any(|line| line == format!("# CoA Custom {CLIENT_VERSION}"));
let state = if !manifest.is_empty() && current && !client_path.join(".coa-races-transaction").exists() {
match patch_files(client_path) {
Ok(files) if files.iter().all(|f| matches_patch(&client_path.join(&f.path), f) && !suffix(&client_path.join(&f.path), "disabled").exists()) => ClientPatchState::Enabled,
Ok(files) if files.iter().all(|f| matches_patch(&suffix(&client_path.join(&f.path), "disabled"), f)) => ClientPatchState::Disabled,
_ => ClientPatchState::PartiallyInstalled,
}
} else if !manifest.is_empty() || patch_files(client_path).is_ok_and(|files| files.iter().filter(|file| file.path.starts_with("Data/") && file.path != "Data/patch-T.MPQ").any(|file| matches_patch(&client_path.join(&file.path), file) || matches_patch(&suffix(&client_path.join(&file.path), "disabled"), file))) {
ClientPatchState::PartiallyInstalled
} else { ClientPatchState::NotInstalled };
ClientPatchStatus { state, installed_mpqs, total_mpqs: RACE_MPQS.len(), has_root_files,
client_path: Some(client_path.to_string_lossy().into_owned()) }
}
#[derive(Serialize, Deserialize)]
struct SavedFile { path: String, existed: bool }
struct PatchTransaction<'a> { root: &'a Path, entries: Vec<SavedFile>, finished: bool }
impl<'a> PatchTransaction<'a> {
fn new(root: &'a Path) -> Result<Self> {
recover_patch_transaction(root)?;
fs::create_dir(root.join(".coa-races-transaction"))?;
Ok(Self { root, entries: Vec::new(), finished: false })
}
fn save(&mut self, path: &Path) -> Result<()> {
let relative = path.strip_prefix(self.root).map_err(|_| Error::Invalid("Patch path escaped the client directory.".into()))?.to_string_lossy().replace('\\', "/");
fsx::safe_join(self.root, &relative)?;
if self.entries.iter().any(|entry| entry.path == relative) { return Ok(()); }
let index = self.entries.len();
self.entries.push(SavedFile { path: relative, existed: path.is_file() });
fsx::atomic_write_json(&self.root.join(".coa-races-transaction/journal.json"), &self.entries)?;
if path.is_file() { fs::rename(path, self.root.join(".coa-races-transaction").join(index.to_string()))?; }
Ok(())
}
fn copy(&mut self, source: &Path, target: &Path) -> Result<()> {
self.save(target)?;
fs::create_dir_all(target.parent().ok_or_else(|| Error::Invalid("Patch file has no parent directory.".into()))?)?;
fs::copy(source, target)?;
Ok(())
}
fn move_file(&mut self, source: &Path, target: &Path) -> Result<()> {
self.save(source)?;
let index = self.entries.iter().position(|entry| self.root.join(&entry.path) == source).unwrap();
// Copy from the journal so rollback retains the previous bytes.
let saved = self.root.join(".coa-races-transaction").join(index.to_string());
self.copy(&saved, target)
}
fn finish(mut self) -> Result<()> {
fsx::atomic_write(&self.root.join(".coa-races-transaction/committed"), b"committed")?;
self.finished = true;
fs::remove_dir_all(self.root.join(".coa-races-transaction"))?;
Ok(())
}
}
impl Drop for PatchTransaction<'_> {
fn drop(&mut self) { if !self.finished { let _ = recover_patch_transaction(self.root); } }
}
fn recover_patch_transaction(root: &Path) -> Result<()> {
let directory = root.join(".coa-races-transaction");
if !directory.is_dir() { return Ok(()); }
if !directory.join("committed").exists() && directory.join("journal.json").exists() {
let entries: Vec<SavedFile> = fsx::read_json(&directory.join("journal.json"))?;
for (index, entry) in entries.iter().enumerate().rev() {
let path = fsx::safe_join(root, &entry.path)?;
let saved = directory.join(index.to_string());
if saved.is_file() {
if path.is_file() { fs::remove_file(&path)?; }
fs::rename(saved, path)?;
} else if !entry.existed && path.is_file() { fs::remove_file(path)?; }
} }
} }
fs::remove_dir_all(directory)?;
tracing::info!(enabled, "custom races client patches toggled");
Ok(()) Ok(())
} }
fn patch_lock(client: &Path) -> Result<File> {
use fs4::fs_std::FileExt;
let lock = fs::OpenOptions::new().read(true).write(true).create(true).truncate(false).open(client.join(".coa-races.lock"))?;
if !lock.try_lock_exclusive()? { return Err(Error::Invalid("Another custom races operation is using this client.".into())); }
Ok(lock)
}
fn preserve_original(tx: &mut PatchTransaction<'_>, active: &Path) -> Result<()> {
let original = suffix(active, "original");
if original.is_file() && fsx::sha256_file(active)? == fsx::sha256_file(&original)? { return Ok(()); }
if original.is_file() {
let previous = suffix(active, &format!("original.previous-{}", uuid::Uuid::new_v4().simple()));
tx.copy(&original, &previous)?;
}
tx.copy(active, &original)
}
/// Preserve launcher replacements, and switch every file owned by the package.
pub fn set_client_patch_enabled(client: &Path, enabled: bool) -> Result<()> {
if !client.is_dir() { return Err(Error::Invalid("Game client directory not found.".into())); }
if crate::client::is_running(client) { return Err(Error::Invalid("Close the game before changing custom races patches.".into())); }
let _lock = patch_lock(client)?;
recover_patch_transaction(client)?;
if !client.join(MANIFEST_FILENAME).is_file() { return Ok(()); }
let files = patch_files(client)?;
if enabled {
for file in &files {
let active = client.join(&file.path);
if !matches_patch(&active, file) && !matches_patch(&suffix(&active, "disabled"), file) {
return Err(Error::Invalid(format!("Custom races file {} was replaced or is missing. Repair the client patch before enabling it.", file.path)));
}
}
}
let mut tx = PatchTransaction::new(client)?;
for file in files {
let active = client.join(&file.path);
let disabled = suffix(&active, "disabled");
let original = suffix(&active, "original");
if enabled {
if active.is_file() && !matches_patch(&active, &file) { preserve_original(&mut tx, &active)?; }
if matches_patch(&disabled, &file) { tx.move_file(&disabled, &active)?; }
} else if matches_patch(&active, &file) {
if disabled.is_file() && !matches_patch(&disabled, &file) {
tx.move_file(&disabled, &suffix(&disabled, &format!("replaced-{}", uuid::Uuid::new_v4().simple())))?;
}
tx.move_file(&active, &disabled)?;
if original.is_file() { tx.copy(&original, &active)?; }
} else if active.is_file() {
preserve_original(&mut tx, &active)?;
}
}
tx.finish()
}
pub fn uninstall_client_patches(client: &Path) -> Result<()> {
if crate::client::is_running(client) { return Err(Error::Invalid("Close the game before removing custom races patches.".into())); }
let _lock = patch_lock(client)?;
recover_patch_transaction(client)?;
if !client.join(MANIFEST_FILENAME).is_file() { return Ok(()); }
let mut tx = PatchTransaction::new(client)?;
for file in patch_files(client)? {
let active = client.join(&file.path);
if matches_patch(&active, &file) {
tx.save(&active)?;
let original = suffix(&active, "original");
if original.is_file() { tx.copy(&original, &active)?; }
}
let disabled = suffix(&active, "disabled");
if active.is_file() && !matches_patch(&active, &file) && !suffix(&active, "original").is_file() {
tx.move_file(&active, &suffix(&active, &format!("replaced-{}", uuid::Uuid::new_v4().simple())))?;
}
if disabled.is_file() {
if !matches_patch(&disabled, &file) { tx.move_file(&disabled, &suffix(&disabled, &format!("replaced-{}", uuid::Uuid::new_v4().simple())))?; }
else { tx.save(&disabled)?; }
}
}
tx.save(&client.join(MANIFEST_FILENAME))?;
tx.finish()
}
fn verify_archive(path: &Path, filename: &str) -> Result<()> { fn verify_archive(path: &Path, filename: &str) -> Result<()> {
let expected = match filename { let expected = match filename {
"CoA-Custom-1.5-main-20261009-cb2a0ca4.zip" => "117f5d99add18191676be6648fb0f2e99019a06c18705c71454e371e7df2afd2", "CoA-Custom-1.5-main-20261009-cb2a0ca4.zip" => "117f5d99add18191676be6648fb0f2e99019a06c18705c71454e371e7df2afd2",
@@ -376,30 +485,12 @@ pub fn install_client_patches(
if crate::client::is_running(client_path) { if crate::client::is_running(client_path) {
return Err(Error::Invalid("Close the game before installing custom races patches.".into())); return Err(Error::Invalid("Close the game before installing custom races patches.".into()));
} }
let data_dir = client_path.join("Data"); let _lock = patch_lock(client_path)?;
recover_patch_transaction(client_path)?;
let staging = tempfile::Builder::new().prefix(".coa-races-stage-").tempdir_in(client_path)?;
let data_dir = staging.path().join("Data");
fs::create_dir_all(&data_dir)?; fs::create_dir_all(&data_dir)?;
// 1. Back up original Ascension.exe and patch-T.MPQ if they exist and haven't been backed up yet
let exe = client_path.join("Ascension.exe");
let exe_bak = client_path.join("Ascension.exe.original");
if exe.is_file() && !exe_bak.is_file() {
report("Backing up original Ascension.exe...", 0.02);
fs::copy(&exe, &exe_bak)?;
}
let t_mpq = data_dir.join("patch-T.MPQ");
let t_mpq_bak = data_dir.join("patch-T.MPQ.original");
if t_mpq.is_file() && !t_mpq_bak.is_file() {
report("Backing up original patch-T.MPQ...", 0.04);
fs::copy(&t_mpq, &t_mpq_bak)?;
}
let dll = client_path.join("dinput8.dll");
let dll_backup = client_path.join("dinput8.dll.original");
if dll.is_file() && !dll_backup.is_file() {
fs::copy(&dll, &dll_backup)?;
}
// 2. Resolve/download archives (0.05 .. 0.50) // 2. Resolve/download archives (0.05 .. 0.50)
let http = reqwest::blocking::Client::builder() let http = reqwest::blocking::Client::builder()
.user_agent(concat!("CoA-Server-Manager/", env!("CARGO_PKG_VERSION"))) .user_agent(concat!("CoA-Server-Manager/", env!("CARGO_PKG_VERSION")))
@@ -470,10 +561,10 @@ pub fn install_client_patches(
if disabled.is_file() { fs::remove_file(disabled)?; } if disabled.is_file() { fs::remove_file(disabled)?; }
installed_mpqs.push(base); installed_mpqs.push(base);
} else if base.eq_ignore_ascii_case("dinput8.dll") { } else if base.eq_ignore_ascii_case("dinput8.dll") {
let dest = client_path.join(&base); let dest = staging.path().join(&base);
let mut out = File::create(&dest)?; let mut out = File::create(&dest)?;
io::copy(&mut zfile, &mut out)?; io::copy(&mut zfile, &mut out)?;
let disabled = client_path.join(format!("{base}.disabled")); let disabled = staging.path().join(format!("{base}.disabled"));
if disabled.is_file() { fs::remove_file(disabled)?; } if disabled.is_file() { fs::remove_file(disabled)?; }
installed_roots.push(base); installed_roots.push(base);
} }
@@ -484,10 +575,10 @@ pub fn install_client_patches(
.unwrap_or_default(); .unwrap_or_default();
if !base.is_empty() { if !base.is_empty() {
let dest = client_path.join(&base); let dest = staging.path().join(&base);
let mut out = File::create(&dest)?; let mut out = File::create(&dest)?;
io::copy(&mut zfile, &mut out)?; io::copy(&mut zfile, &mut out)?;
let disabled = client_path.join(format!("{base}.disabled")); let disabled = staging.path().join(format!("{base}.disabled"));
if disabled.is_file() { fs::remove_file(disabled)?; } if disabled.is_file() { fs::remove_file(disabled)?; }
installed_roots.push(base); installed_roots.push(base);
} }
@@ -516,7 +607,35 @@ pub fn install_client_patches(
manifest_body.push_str(&format!("ROOT:{r}\n")); manifest_body.push_str(&format!("ROOT:{r}\n"));
} }
let bundled: std::collections::BTreeMap<String, String> = serde_json::from_str(include_str!("custom_races_hashes.json"))?;
let mut payload = Vec::new();
for path in installed_mpqs.iter().map(|name| format!("Data/{name}")).chain(installed_roots.iter().cloned()) {
let staged = fsx::safe_join(staging.path(), &path)?;
let hash = fsx::sha256_file(&staged)?;
if bundled.get(&path) != Some(&hash) { return Err(Error::Invalid(format!("Custom races file {path} failed verification."))); }
manifest_body.push_str(&format!("SHA256:{hash}:{path}\n"));
payload.push(PatchFile { path, sha256: hash });
}
if cancel.is_set() { return Err(Error::Invalid("Operation cancelled.".into())); }
if payload.len() != bundled.len() { return Err(Error::Invalid("Custom races archives are missing required runtime files.".into())); }
let previous = patch_files(client_path)?;
let mut tx = PatchTransaction::new(client_path)?;
for file in payload {
let dest = fsx::safe_join(client_path, &file.path)?;
if dest.is_file() && !previous.iter().any(|old| old.path == file.path && matches_patch(&dest, old)) && !matches_patch(&dest, &file) {
preserve_original(&mut tx, &dest)?;
}
tx.copy(&staging.path().join(&file.path), &dest)?;
let disabled = suffix(&dest, "disabled");
if disabled.is_file() {
if !previous.iter().any(|old| old.path == file.path && matches_patch(&disabled, old)) && !matches_patch(&disabled, &file) {
tx.move_file(&disabled, &suffix(&disabled, &format!("replaced-{}", uuid::Uuid::new_v4().simple())))?;
} else { tx.save(&disabled)?; }
}
}
tx.save(&manifest_path)?;
fsx::atomic_write(&manifest_path, manifest_body.as_bytes())?; fsx::atomic_write(&manifest_path, manifest_body.as_bytes())?;
tx.finish()?;
report("Custom races client patches installed successfully!", 1.0); report("Custom races client patches installed successfully!", 1.0);
tracing::info!( tracing::info!(
mpqs = installed_mpqs.len(), mpqs = installed_mpqs.len(),
@@ -531,23 +650,140 @@ pub fn install_client_patches(
mod tests { mod tests {
use super::*; use super::*;
#[test] fn record_files(root: &Path, names: &[&str]) {
fn disabling_restores_original_client_files_and_enabling_restores_custom_files() { let mut manifest = format!("# CoA Custom {CLIENT_VERSION}\n");
let temp = tempfile::tempdir().unwrap(); for name in names {
let data = temp.path().join("Data"); let (kind, base) = name.strip_prefix("Data/").map_or(("ROOT", *name), |base| ("MPQ", base));
fs::create_dir_all(&data).unwrap(); manifest.push_str(&format!("{kind}:{base}\nSHA256:{}:{name}\n", fsx::sha256_file(&root.join(name)).unwrap()));
for path in [data.join("patch-T.MPQ"), temp.path().join("Ascension.exe"), temp.path().join("dinput8.dll")] {
fs::write(&path, b"custom").unwrap();
let backup = path.with_extension(format!("{}.original", path.extension().unwrap().to_string_lossy()));
fs::write(&backup, b"original").unwrap();
} }
fs::write(temp.path().join(MANIFEST_FILENAME), "MPQ:patch-T.MPQ\n").unwrap(); fs::write(root.join(MANIFEST_FILENAME), manifest).unwrap();
set_client_patch_enabled(temp.path(), false).unwrap(); }
assert_eq!(fs::read(data.join("patch-T.MPQ")).unwrap(), b"original");
assert_eq!(fs::read(temp.path().join("Ascension.exe")).unwrap(), b"original"); #[test]
set_client_patch_enabled(temp.path(), true).unwrap(); #[ignore = "Requires the three downloaded release archives"]
assert_eq!(fs::read(data.join("patch-T.MPQ")).unwrap(), b"custom"); fn bundled_hashes_match_verified_release_archives() {
assert_eq!(fs::read(temp.path().join("Ascension.exe")).unwrap(), b"custom"); use sha2::{Digest, Sha256};
let folder = PathBuf::from(std::env::var_os("COA_RACES_ARCHIVE_DIR").expect("COA_RACES_ARCHIVE_DIR"));
let expected: std::collections::BTreeMap<String, String> = serde_json::from_str(include_str!("custom_races_hashes.json")).unwrap();
let mut actual = std::collections::BTreeMap::new();
for (name, _) in ARCHIVES {
let path = folder.join(name);
verify_archive(&path, name).unwrap();
let mut archive = zip::ZipArchive::new(File::open(path).unwrap()).unwrap();
for index in 0..archive.len() {
let mut entry = archive.by_index(index).unwrap();
let name = entry.name().replace('\\', "/");
if entry.is_dir() { continue; }
let relative = if let Some(name) = name.split("files/client_root/").nth(1) { name.to_string() }
else if let Some(name) = name.split("files/client/").nth(1) { if name == "dinput8.dll" { name.to_string() } else { format!("Data/{name}") } }
else { continue };
let mut hash = Sha256::new();
let mut buffer = vec![0; 1024 * 1024];
loop { let read = entry.read(&mut buffer).unwrap(); if read == 0 { break; } hash.update(&buffer[..read]); }
actual.insert(relative, hex::encode(hash.finalize()));
}
}
assert_eq!(actual, expected);
}
#[test]
fn another_patch_operation_cannot_enter_the_same_client() {
let temp = tempfile::tempdir().unwrap();
let first = patch_lock(temp.path()).unwrap();
assert!(patch_lock(temp.path()).is_err());
drop(first);
patch_lock(temp.path()).unwrap();
}
#[test]
fn switching_preserves_launcher_updates_for_every_owned_file() {
let temp = tempfile::tempdir().unwrap();
let root = temp.path();
fs::create_dir_all(root.join("Data")).unwrap();
let names = ["Data/patch-T.MPQ", "Data/patch-ZE1.MPQ", "Ascension.exe", "dinput8.dll", "EsteriaAppearance.dll"];
for name in names { fs::write(root.join(name), b"custom").unwrap(); fs::write(suffix(&root.join(name), "original"), b"old official").unwrap(); }
record_files(root, &names);
set_client_patch_enabled(root, false).unwrap();
for name in names { assert_eq!(fs::read(root.join(name)).unwrap(), b"old official"); fs::write(root.join(name), b"new official").unwrap(); }
set_client_patch_enabled(root, true).unwrap();
for name in names { assert_eq!(fs::read(root.join(name)).unwrap(), b"custom"); assert_eq!(fs::read(suffix(&root.join(name), "original")).unwrap(), b"new official"); }
// An official launcher can also replace a currently enabled file.
fs::write(root.join("Ascension.exe"), b"newest official").unwrap();
assert_eq!(client_patch_status(root).state, ClientPatchState::PartiallyInstalled);
set_client_patch_enabled(root, false).unwrap();
assert_eq!(fs::read(root.join("Ascension.exe")).unwrap(), b"newest official");
assert!(set_client_patch_enabled(root, true).unwrap_err().to_string().contains("Repair"));
uninstall_client_patches(root).unwrap();
assert_eq!(fs::read(root.join("Ascension.exe")).unwrap(), b"newest official");
assert_eq!(client_patch_status(root).state, ClientPatchState::NotInstalled);
}
#[test]
fn failed_and_interrupted_transactions_restore_previous_bytes() {
let temp = tempfile::tempdir().unwrap();
let root = temp.path();
let file = root.join("Ascension.exe");
fs::write(&file, b"previous").unwrap();
{
let mut tx = PatchTransaction::new(root).unwrap();
tx.save(&file).unwrap();
fs::write(&file, b"replacement").unwrap();
let staged = root.join("staged.dll");
fs::write(&staged, b"new").unwrap();
tx.copy(&staged, &root.join("Data/new.dll")).unwrap();
assert_eq!(fs::read(root.join("Data/new.dll")).unwrap(), b"new");
}
assert_eq!(fs::read(&file).unwrap(), b"previous");
assert!(!root.join("Data/new.dll").exists());
let mut tx = PatchTransaction::new(root).unwrap();
tx.save(&file).unwrap();
fs::write(&file, b"interrupted").unwrap();
std::mem::forget(tx);
recover_patch_transaction(root).unwrap();
assert_eq!(fs::read(&file).unwrap(), b"previous");
}
#[test]
fn existing_backups_and_foreign_disabled_files_are_retained() {
let temp = tempfile::tempdir().unwrap();
let root = temp.path();
let file = root.join("dinput8.dll");
fs::write(&file, b"custom").unwrap();
record_files(root, &["dinput8.dll"]);
fs::write(suffix(&file, "disabled"), b"third party").unwrap();
fs::write(suffix(&file, "original"), b"original").unwrap();
set_client_patch_enabled(root, false).unwrap();
assert_eq!(fs::read(&file).unwrap(), b"original");
assert!(fs::read_dir(root).unwrap().flatten().any(|entry| entry.file_name().to_string_lossy().contains("replaced-")));
fs::write(&file, b"updated original").unwrap();
set_client_patch_enabled(root, true).unwrap();
assert!(fs::read_dir(root).unwrap().flatten().any(|entry| entry.file_name().to_string_lossy().contains("original.previous-")));
}
#[test]
fn uninstall_moves_corrupted_custom_only_assets_out_of_the_active_client() {
let temp = tempfile::tempdir().unwrap();
let root = temp.path();
fs::create_dir_all(root.join("Data")).unwrap();
let file = root.join("Data/patch-ZE1.MPQ");
fs::write(&file, b"custom").unwrap();
record_files(root, &["Data/patch-ZE1.MPQ"]);
fs::write(&file, b"corrupted custom").unwrap();
uninstall_client_patches(root).unwrap();
assert!(!file.exists());
assert!(fs::read_dir(root.join("Data")).unwrap().flatten().any(|entry| entry.file_name().to_string_lossy().contains("replaced-")));
assert_eq!(client_patch_status(root).state, ClientPatchState::NotInstalled);
}
#[test]
fn unknown_or_corrupt_bytes_are_not_reported_as_enabled() {
let temp = tempfile::tempdir().unwrap();
let root = temp.path();
fs::create_dir_all(root.join("Data")).unwrap();
for name in RACE_MPQS { fs::write(root.join("Data").join(name), b"corrupt").unwrap(); }
fs::write(root.join("dinput8.dll"), b"corrupt").unwrap();
fs::write(root.join(MANIFEST_FILENAME), format!("# CoA Custom {CLIENT_VERSION}\n")).unwrap();
assert_eq!(client_patch_status(root).state, ClientPatchState::PartiallyInstalled);
} }
#[test] #[test]
@@ -595,6 +831,8 @@ mod tests {
fs::write(client_path.join("dinput8.dll"), b"test dll").unwrap(); fs::write(client_path.join("dinput8.dll"), b"test dll").unwrap();
fs::write(client_path.join("EsteriaAppearance.dll"), b"test dll").unwrap(); fs::write(client_path.join("EsteriaAppearance.dll"), b"test dll").unwrap();
let names: Vec<String> = RACE_MPQS.iter().map(|name| format!("Data/{name}")).chain(["dinput8.dll".into(), "EsteriaAppearance.dll".into()]).collect();
record_files(client_path, &names.iter().map(String::as_str).collect::<Vec<_>>());
let st = client_patch_status(client_path); let st = client_patch_status(client_path);
assert_eq!(st.state, ClientPatchState::Enabled); assert_eq!(st.state, ClientPatchState::Enabled);
assert_eq!(st.installed_mpqs, RACE_MPQS.len()); assert_eq!(st.installed_mpqs, RACE_MPQS.len());
@@ -0,0 +1,50 @@
{
"Data/patch-ZE1.MPQ": "69d79dbbea54ec0312c37770debc79c7bc9ce2e21eedef99c03cd8d911955283",
"Data/patch-ZE2.MPQ": "1a41cae77ad730e9cf69e8d63fd12ae3a579418bb550d351fff469573a97ac3c",
"Data/patch-ZE3.MPQ": "b587202c21b6f580682b601b7c2e905fbfa766276e74733db55c1bddbffb7f87",
"Data/patch-ZEA.MPQ": "78fd10ec5262ae2417eba9700d2172553bbc1e5cfb0b597aada8f1753ca46d9d",
"Data/patch-ZHA.MPQ": "0fc6ebeafe1d14192dc64bafc90bde3c49230df1297f98bf65900a3bcf953617",
"Data/patch-ZZE.MPQ": "4b1e289e12c82644cb78f50170e6b5fd53918eb2de834f9e0cebddd81873a8bb",
"Data/patch-ZZR.MPQ": "5a7575e592dc0c8a6913e0d946bbe06fa0ca2e4d817ef1f8548d3d13142bcbd3",
"Ascension.exe": "e2c347019d554a59639e5978fd68e50e906973ab313c6573cc56ca82e8e3c547",
"EsteriaAppearance.bin": "b3fb7c69b7600c39f888ea1925701be5667097dcb02bb6ddd830e5489306bb50",
"EsteriaAppearance.dll": "392c5a2a25f9a69d705bdf841bb899aab768d4a3ee62734d576286c7198710d8",
"EsteriaAppearanceGeometry.bin": "c95c53ca19c53c3434e12b99c1966f9c015ec3944c46dff7784d5e4ffc472d5d",
"EsteriaAppearanceMaterials.bin": "f72f027f54a55c05aa0f76b457b97b484fe0e1aedc0e068cc0e0ca53e1878cba",
"EsteriaCosmeticWings.bin": "57352c28459d073a29b3014d33b70f3b3756afa37fa9583ef6b30d503422ac3f",
"EsteriaEarthen.bin": "8a0db93ba2d5c756b44ed84f2f7bc7c15eef13be6a7d87baf1383c6c0c624e02",
"EsteriaGnoll.bin": "cfacc8e681bb8e54a4f01ee9c12a91bf0bd23a23527bb548d4dc21ec1b33eea2",
"EsteriaGnollTextures.bin": "1ba9133a75dad291d98a068b2dcde01f31a897a1764cd7f3e2c316c288a8f605",
"EsteriaHaranir.bin": "59f31d00e372fd2646e1cf0d9d3d5d671b31edd60ff7b862f8d1ce7e53ba1f2f",
"EsteriaHaranirTextures.bin": "99948ca570be2d376f0c67e3b8088739b6fa9f9d2c73985e19f68df77689a229",
"EsteriaHighmountain.bin": "e83349252ad2687ac23fcfc5623db7401cf32e5faf47a5a7be20c2f94b014938",
"EsteriaNaga.bin": "e87547cff5d09500c294f8b06935d134cdd0bbb962e294a72de09404505bd8b3",
"EsteriaNagaTextures.bin": "57ec560f99c1d48ac1e8f6a797c156513b99e7d349e3071afe405f812d159ae3",
"EsteriaSaberon.bin": "7735c9325c807c5125760d87f323d6b7d4162fb542c1d8b5f435ea2d6b9a4daa",
"EsteriaSaberonCoverage.bin": "9cdc227f08329e1245d2b864a996e7a772c96ecdbe5d81925f4d60cdbe4fa11e",
"EsteriaSaberonTextures.bin": "1ba9133a75dad291d98a068b2dcde01f31a897a1764cd7f3e2c316c288a8f605",
"EsteriaSethrak.bin": "bd14857a8c11fdf8027128763293701586b2102f9a6539d33a727014789fd606",
"EsteriaSethrakTextures.bin": "d2b2cf58087a391f00198008fe871edd400ddf28d54a3a05674df74c5198528a",
"EsteriaThinHuman.bin": "75794d192ea0c228b3da7bf7d0bdff1119f79d3f9bfef6650cd5e1a2b5d106eb",
"EsteriaThinHumanTextures.bin": "02aeb4c05893d06125b8b58fdb7c2a56fe3d66a7d094706a44b43cb503d1731e",
"EsteriaTuskarr.bin": "ecbe7ef490ba67eca029a57639192db61238522618491549766fe38529914387",
"EsteriaTuskarrTextures.bin": "e2116c2c83adea079126fd5da765d20da24f044d4f161c4124e4368cb3d6bc71",
"EsteriaVrykul.bin": "39e2b7b4c67997dbbd34bae840bd606a59290f7f2fc82565a0ba00090335415c",
"EsteriaVrykulTextures.bin": "46098750a0e235724c6e9cc8d9d4e26550aa47bef95fd5f0f82efe5e945bf296",
"EsteriaVulpera.bin": "c5434993b9af4a17d881965e4735cd2ac379e39c7142aac9844adff9528562d4",
"EsteriaVulperaTextures.bin": "1ab844e74684aced2b069f1b91cd563aade45e05bd5e23f866a6c0c301cb098e",
"dinput8.dll": "f8de78606c241fb3911dce22faf68f5b9f9885b142b183c1e2c09ddc8f7e380c",
"Data/patch-T.MPQ": "9403e0680c74754eb0cb063718119aa6ace3616f7cecf488c8faf46f22505ae5",
"Data/patch-ZE5.MPQ": "476b5a1fcf69f64fdb281e3b445362b936d016066ccd12f897acfcf200d6c0cf",
"Data/patch-ZE6.MPQ": "762592c9ed950b4a7b6c7d85d45050b30fa3f35d53e348ee1e1516fdbb7e5484",
"Data/patch-ZE7.MPQ": "de54b0189d242763d2872223419a259b6b8a4b380c24b50a2ef9c6fa44466248",
"Data/patch-ZE8.MPQ": "1bc5691fb84a84f3e7a0a70baaa9192a97b4ec5906ee37c85838ffe08adef934",
"Data/patch-ZE9.MPQ": "d49c94463e9548e76378ce2c0454d8f204f0745c8c0de32b6dce7f0b0fd67c4a",
"Data/patch-ZES.MPQ": "a2d9348f917f745c7aa25b2eed96efa312f7b2d2f62cb86a4f2eaabc2dfa895f",
"Data/patch-ZG.MPQ": "48979e1fda775f8deb47bffa48e0a468595d4c71286fee518f51dc5801c5ca39",
"Data/patch-ZH.MPQ": "5e1d2fe287053abba703d7af381e10096c6525ba477ffed3971c2fc4f93e919c",
"Data/patch-ZHM.MPQ": "317d3ae00f0bd674b358af07544976acb7804aa6d8b19d1788ad96030e8c9bf0",
"Data/patch-ZJ.MPQ": "f821e99add86ef68d108c5ec466328c97677d3ed52f7944e200f3fe38c13b4de",
"Data/patch-ZM.MPQ": "424ab1978986e854551633983a94bd15beba6328aabea8c02f98eaa32f6f0b61",
"Data/patch-ZVU.MPQ": "c679b85a2e97344395756b54d2cf6abefe4e80e74944cb55b6e573ad17b7d020"
}
+15
View File
@@ -228,6 +228,8 @@ pub(crate) fn verify(point: &Path, snapshot: &Snapshot) -> Result<()> {
pub(crate) fn rehearsal_copy(root: &Path, meta: &Path, point: &Path, snapshot: &Snapshot) -> Result<PathBuf> { pub(crate) fn rehearsal_copy(root: &Path, meta: &Path, point: &Path, snapshot: &Snapshot) -> Result<PathBuf> {
verify(point, snapshot)?; verify(point, snapshot)?;
let canonical = fsx::canonicalize_lenient(root)?;
let root = canonical.as_path();
let destination = meta.join("rehearsals").join(uuid::Uuid::new_v4().simple().to_string()).join("server"); let destination = meta.join("rehearsals").join(uuid::Uuid::new_v4().simple().to_string()).join("server");
let mut files = BTreeMap::new(); let mut files = BTreeMap::new();
let mut directories = vec![root.to_path_buf()]; let mut directories = vec![root.to_path_buf()];
@@ -475,4 +477,17 @@ mod tests {
fsx::atomic_write(&root.join("mysql/data/extra.ibd"), b"new data").unwrap(); fsx::atomic_write(&root.join("mysql/data/extra.ibd"), b"new data").unwrap();
assert!(unchanged(&root, &snapshot).is_err()); assert!(unchanged(&root, &snapshot).is_err());
} }
#[test]
fn rehearsal_copy_succeeds_with_nested_directories_and_unnormalized_root() {
let (_temp, root, meta, point, snapshot) = fixture();
let meta_obj = crate::registry::InstallMeta::new(crate::registry::InstallKind::New, &root);
fsx::atomic_write_json(&meta.join("install.json"), &meta_obj).unwrap();
fsx::atomic_write(&root.join("Core/worldserver.exe"), b"exe").unwrap();
fsx::atomic_write(&root.join("Core/configs/worldserver.conf"), b"conf").unwrap();
fsx::atomic_write(&root.join("Settings/repack.json"), b"{}").unwrap();
let dest = rehearsal_copy(&root, &meta, &point, &snapshot).unwrap();
assert_eq!(fs::read(dest.join("Core/configs/worldserver.conf")).unwrap(), b"conf");
assert_eq!(fs::read(dest.join("mysql/data/characters.ibd")).unwrap(), b"saved");
}
} }
+30 -1
View File
@@ -29,6 +29,14 @@ pub fn qualify_upgrade(base: &Path, source: &Path, candidate: &Path, fixture: &P
if fixture.exists() || !fixture.file_name().is_some_and(|name| name.to_string_lossy().starts_with("coa-schema-fixture-")) { if fixture.exists() || !fixture.file_name().is_some_and(|name| name.to_string_lossy().starts_with("coa-schema-fixture-")) {
return Err(Error::Invalid("Upgrade qualification requires a new disposable coa-schema-fixture-* directory.".into())); return Err(Error::Invalid("Upgrade qualification requires a new disposable coa-schema-fixture-* directory.".into()));
} }
let fixture_root = std::path::absolute(fixture)?;
let fixture = fixture_root.as_path();
let base_root = fsx::canonicalize_lenient(base)?;
let base = base_root.as_path();
let source_root = fsx::canonicalize_lenient(source)?;
let source = source_root.as_path();
let candidate_root = fsx::canonicalize_lenient(candidate)?;
let candidate = candidate_root.as_path();
let metadata = crate::registry::metadata_dir_for(fixture)?; let metadata = crate::registry::metadata_dir_for(fixture)?;
if metadata.exists() { return Err(Error::Invalid("Upgrade fixture metadata already exists.".into())); } if metadata.exists() { return Err(Error::Invalid("Upgrade fixture metadata already exists.".into())); }
let (base_manifest, base_bytes) = pkgsource::fetch_manifest(&pkgsource::Source::Dir(base.into()), trusted_key)?; let (base_manifest, base_bytes) = pkgsource::fetch_manifest(&pkgsource::Source::Dir(base.into()), trusted_key)?;
@@ -157,6 +165,10 @@ pub fn validate_startup(fixture: &Path, tree: &Path, base: &Path, trusted_key: &
|| std::fs::read(fixture.join(MARKER)).ok().as_deref() != Some(b"disposable release-schema fixture") { || std::fs::read(fixture.join(MARKER)).ok().as_deref() != Some(b"disposable release-schema fixture") {
return Err(Error::Invalid("Startup qualification requires a disposable release-schema fixture.".into())); return Err(Error::Invalid("Startup qualification requires a disposable release-schema fixture.".into()));
} }
let fixture_root = fsx::canonicalize_lenient(fixture)?;
let fixture = fixture_root.as_path();
let tree_root = fsx::canonicalize_lenient(tree)?;
let tree = tree_root.as_path();
let metadata = crate::registry::metadata_dir_for(fixture)?; let metadata = crate::registry::metadata_dir_for(fixture)?;
if metadata.exists() { return Err(Error::Invalid("Startup fixture already has Manager metadata; use a fresh fixture.".into())); } if metadata.exists() { return Err(Error::Invalid("Startup fixture already has Manager metadata; use a fresh fixture.".into())); }
schema_check::require_release_contract(tree)?; schema_check::require_release_contract(tree)?;
@@ -190,7 +202,11 @@ pub fn validate_startup(fixture: &Path, tree: &Path, base: &Path, trusted_key: &
package::extract_selected(base, &manifest, fixture, &|path| path.starts_with("Data/"), &|_, _| {})?; package::extract_selected(base, &manifest, fixture, &|path| path.starts_with("Data/"), &|_, _| {})?;
for relative in files { for relative in files {
let target = fsx::ensure_within(fixture, &fixture.join(&relative))?; let target = fsx::ensure_within(fixture, &fixture.join(&relative))?;
fsx::atomic_write(&target, &std::fs::read(tree.join(relative))?)?; fsx::atomic_write(&target, &std::fs::read(tree.join(&relative))?)?;
let expected = fsx::sha256_file(&tree.join(relative))?;
if fsx::sha256_file(&target)? != expected {
return Err(Error::Invalid("Startup candidate copy failed verification.".into()));
}
} }
let meta = crate::registry::InstallMeta::new(crate::registry::InstallKind::New, fixture); let meta = crate::registry::InstallMeta::new(crate::registry::InstallKind::New, fixture);
crate::registry::MetaDir::create(fixture, &meta)?; crate::registry::MetaDir::create(fixture, &meta)?;
@@ -233,6 +249,19 @@ mod tests {
use base64::{engine::general_purpose::STANDARD, Engine}; use base64::{engine::general_purpose::STANDARD, Engine};
use ed25519_dalek::{Signer, SigningKey}; use ed25519_dalek::{Signer, SigningKey};
#[test]
fn relative_startup_fixture_targets_replace_the_original_location() {
let directory = tempfile::Builder::new().prefix("coa-schema-fixture-path-test-").tempdir_in(".").unwrap();
let current = std::env::current_dir().unwrap();
let relative = directory.path().strip_prefix(&current).unwrap();
fsx::atomic_write(&relative.join("Core/worldserver.exe"), b"old").unwrap();
let root = fsx::canonicalize_lenient(relative).unwrap();
let target = fsx::ensure_within(&root, &root.join("Core/worldserver.exe")).unwrap();
fsx::atomic_write(&target, b"candidate").unwrap();
assert_eq!(std::fs::read(relative.join("Core/worldserver.exe")).unwrap(), b"candidate");
assert!(!root.join(relative).join("Core/worldserver.exe").exists());
}
#[test] #[test]
fn startup_qualification_refuses_real_server_folders_before_writes() { fn startup_qualification_refuses_real_server_folders_before_writes() {
let directory = tempfile::tempdir().unwrap(); let directory = tempfile::tempdir().unwrap();
+61 -13
View File
@@ -687,6 +687,25 @@ fn restore_transaction(root: &Path, meta: &Path, before: &Path, txn: &mut Txn, e
} }
fn apply_ops(root: &Path, tree: &Path, before: &Path, files: &[FileEntry], txn: &mut Txn, meta_dir: &Path, fail_after: Option<usize>) -> Result<()> { fn apply_ops(root: &Path, tree: &Path, before: &Path, files: &[FileEntry], txn: &mut Txn, meta_dir: &Path, fail_after: Option<usize>) -> Result<()> {
if fail_after == Some(0) && !txn.ops.is_empty() {
return Err(Error::Invalid("simulated failure".into()));
}
let entries: BTreeMap<_, _> = files.iter().map(|entry| (entry.path.as_str(), entry)).collect();
// Prepare every recovery copy before changing any destination. One durable journal
// can then cover the entire file phase: recovery restores old files even if their
// replacement was not reached, and removes newly created files only by exact hash.
// Rewriting the full journal twice per file makes large navigation updates quadratic.
for op in &txn.ops {
let target = fsx::ensure_within(root, &fsx::safe_join(root, &op.path)?)?;
if op.had_previous {
let keep = fsx::safe_join(before, &op.path)?;
fs::create_dir_all(keep.parent().unwrap())?;
fsx::atomic_write(&keep, &fs::read(&target)?)?;
txn.recovery_hashes.insert(op.path.clone(), fsx::sha256_file(&keep)?);
}
}
for op in &mut txn.ops { op.started = true; }
save(meta_dir, txn)?;
let mut completed = 0usize; let mut completed = 0usize;
for i in 0..txn.ops.len() { for i in 0..txn.ops.len() {
if fail_after == Some(completed) { if fail_after == Some(completed) {
@@ -695,17 +714,7 @@ fn apply_ops(root: &Path, tree: &Path, before: &Path, files: &[FileEntry], txn:
let (path, action) = (txn.ops[i].path.clone(), txn.ops[i].action); let (path, action) = (txn.ops[i].path.clone(), txn.ops[i].action);
let target = fsx::ensure_within(root, &fsx::safe_join(root, &path)?)?; let target = fsx::ensure_within(root, &fsx::safe_join(root, &path)?)?;
let staged = fsx::safe_join(tree, &path)?; let staged = fsx::safe_join(tree, &path)?;
let entry = files.iter().find(|f| f.path == path).expect("listed"); let entry = entries.get(path.as_str()).expect("listed");
if target.is_file() {
let keep = fsx::safe_join(before, &path)?;
fs::create_dir_all(keep.parent().unwrap())?;
fsx::atomic_write(&keep, &fs::read(&target)?)?;
txn.recovery_hashes.insert(path.clone(), fsx::sha256_file(&keep)?);
}
// Journal only after the old bytes are safely saved; a crash during backup must not
// turn an untouched file into a rollback operation with a missing saved copy.
txn.ops[i].started = true;
save(meta_dir, txn)?;
fs::create_dir_all(target.parent().unwrap())?; fs::create_dir_all(target.parent().unwrap())?;
match action { match action {
Action::Create | Action::Replace => { Action::Create | Action::Replace => {
@@ -730,10 +739,9 @@ fn apply_ops(root: &Path, tree: &Path, before: &Path, files: &[FileEntry], txn:
Action::Skip | Action::Conflict => {} Action::Skip | Action::Conflict => {}
} }
txn.ops[i].done = true; txn.ops[i].done = true;
save(meta_dir, txn)?;
completed += 1; completed += 1;
} }
Ok(()) save(meta_dir, txn)
} }
/// Put every touched file back the way it was. Files created by the update (no previous version) are removed only if /// Put every touched file back the way it was. Files created by the update (no previous version) are removed only if
@@ -1544,6 +1552,46 @@ mod tests {
assert_eq!(fs::read(saved).unwrap(), b"my-custom-build", "the replaced custom build is kept for rollback"); assert_eq!(fs::read(saved).unwrap(), b"my-custom-build", "the replaced custom build is kept for rollback");
} }
#[test]
fn power_loss_during_bulk_files_restores_written_and_unwritten_files() {
let d = tempfile::tempdir().unwrap();
let root = d.path().join("root");
let meta = d.path().join("meta");
let tree = d.path().join("tree");
let before = meta.join("updates/bulk/before");
let mut files = Vec::new();
let mut ops = Vec::new();
for (path, previous) in [("Data/maps/first.map", true), ("Data/maps/new.map", false), ("Data/maps/last.map", true)] {
if previous { write(&root, path, b"old"); }
write(&tree, path, b"new");
let hash = fsx::sha256_file(&tree.join(path)).unwrap();
files.push(FileEntry { path: path.into(), sha256: hash.clone(), size: 3, policy: ReplacePolicy::Replace, owner: crate::manifest::Owner::Core });
ops.push(Op { path: path.into(), action: if previous { Action::Replace } else { Action::Create }, reason: None,
new_sha256: hash, had_previous: previous, started: false, done: false });
}
let mut txn = Txn { id: "bulk".into(), state: State::Applying, from_version: Some("1".into()), to_version: "2".into(),
recovery_point: None, databases_started: false, ops, message: None, recovery_hashes: BTreeMap::new() };
fs::create_dir_all(before.parent().unwrap()).unwrap();
assert!(apply_ops(&root, &tree, &before, &files, &mut txn, &meta, Some(2)).is_err());
// A power loss sees the pre-write checkpoint, not the in-memory completed flags.
let mut durable = load(&meta, "bulk").unwrap();
assert!(durable.ops.iter().all(|op| op.started && !op.done));
assert_eq!(fs::read(root.join("Data/maps/last.map")).unwrap(), b"old");
restore_files(&root, &before, &mut durable).unwrap();
assert_eq!(fs::read(root.join("Data/maps/first.map")).unwrap(), b"old");
assert_eq!(fs::read(root.join("Data/maps/last.map")).unwrap(), b"old");
assert!(!root.join("Data/maps/new.map").exists());
// If preparing any recovery copy fails, no destination may be changed.
for op in &mut durable.ops { op.started = false; op.done = false; }
durable.recovery_hashes.clear();
save(&meta, &durable).unwrap();
fs::remove_file(root.join("Data/maps/last.map")).unwrap();
assert!(apply_ops(&root, &tree, &before, &files, &mut durable, &meta, None).is_err());
assert_eq!(fs::read(root.join("Data/maps/first.map")).unwrap(), b"old");
assert!(!root.join("Data/maps/new.map").exists());
assert!(load(&meta, "bulk").unwrap().ops.iter().all(|op| !op.started));
}
#[test] #[test]
fn failure_in_the_middle_of_applying_restores_every_file_byte_for_byte() { fn failure_in_the_middle_of_applying_restores_every_file_byte_for_byte() {
for fail_after in [0usize, 1, 2] { for fail_after in [0usize, 1, 2] {
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "coa-server-manager", "name": "coa-server-manager",
"version": "0.7.0", "version": "0.6.15",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "coa-server-manager", "name": "coa-server-manager",
"version": "0.7.0", "version": "0.6.15",
"dependencies": { "dependencies": {
"@tauri-apps/api": "^2.12.0", "@tauri-apps/api": "^2.12.0",
"@tauri-apps/plugin-dialog": "^2.8.0", "@tauri-apps/plugin-dialog": "^2.8.0",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "coa-server-manager", "name": "coa-server-manager",
"private": true, "private": true,
"version": "0.7.0", "version": "0.6.15",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"type": "module", "type": "module",
"scripts": { "scripts": {
+13 -5
View File
@@ -668,9 +668,9 @@ async fn module_set_enabled(state: State<'_, AppState>, id: String, module: Stri
#[tauri::command] #[tauri::command]
async fn custom_races_status(state: State<'_, AppState>, id: String) -> std::result::Result<Option<coa_core::custom_races::ClientPatchStatus>, UiError> { async fn custom_races_status(state: State<'_, AppState>, id: String) -> std::result::Result<Option<coa_core::custom_races::ClientPatchStatus>, UiError> {
let root = path_of(&state, &id)?; let ctx = client_context(&state, &id)?;
blocking(move || { blocking(move || {
let client = linked_client(&root)?; let client = ctx.linked();
Ok(client.as_deref().map(coa_core::custom_races::client_patch_status)) Ok(client.as_deref().map(coa_core::custom_races::client_patch_status))
}) })
.await .await
@@ -678,12 +678,12 @@ async fn custom_races_status(state: State<'_, AppState>, id: String) -> std::res
#[tauri::command] #[tauri::command]
async fn custom_races_install(app: AppHandle, state: State<'_, AppState>, id: String) -> std::result::Result<(), UiError> { async fn custom_races_install(app: AppHandle, state: State<'_, AppState>, id: String) -> std::result::Result<(), UiError> {
let root = path_of(&state, &id)?; let ctx = client_context(&state, &id)?;
let _guard = BusyGuard::acquire(&state, &id)?; let _guard = BusyGuard::acquire(&state, &id)?;
let cancel = begin_client_job(&state)?; let cancel = begin_client_job(&state)?;
let sid = id.clone(); let sid = id.clone();
let result = blocking(move || { let result = blocking(move || {
let client = linked_client(&root)?.ok_or_else(|| Error::Invalid("No game client is linked to this server.".into()))?; let client = ctx.require()?;
coa_core::custom_races::install_client_patches(&client, &cancel, &|step, percent| { coa_core::custom_races::install_client_patches(&client, &cancel, &|step, percent| {
let _ = app.emit("custom-races-progress", serde_json::json!({ let _ = app.emit("custom-races-progress", serde_json::json!({
"id": sid, "id": sid,
@@ -691,7 +691,7 @@ async fn custom_races_install(app: AppHandle, state: State<'_, AppState>, id: St
"percent": percent, "percent": percent,
})); }));
})?; })?;
let enabled = coa_core::modules::list(&root).iter().any(|module| module.id == "custom-races" && module.enabled); let enabled = ctx.root.as_ref().map_or(true, |root| coa_core::modules::list(root).iter().any(|module| module.id == "custom-races" && module.enabled));
coa_core::custom_races::set_client_patch_enabled(&client, enabled) coa_core::custom_races::set_client_patch_enabled(&client, enabled)
}) })
.await; .await;
@@ -699,6 +699,13 @@ async fn custom_races_install(app: AppHandle, state: State<'_, AppState>, id: St
result result
} }
#[tauri::command]
async fn custom_races_uninstall(state: State<'_, AppState>, id: String) -> std::result::Result<(), UiError> {
let ctx = client_context(&state, &id)?;
let _guard = BusyGuard::acquire(&state, &id)?;
blocking(move || coa_core::custom_races::uninstall_client_patches(&ctx.require()?)).await
}
#[tauri::command] #[tauri::command]
async fn custom_races_toggle_client(state: State<'_, AppState>, id: String, enabled: bool) -> std::result::Result<(), UiError> { async fn custom_races_toggle_client(state: State<'_, AppState>, id: String, enabled: bool) -> std::result::Result<(), UiError> {
let root = path_of(&state, &id)?; let root = path_of(&state, &id)?;
@@ -1764,6 +1771,7 @@ pub fn run() {
console_command, console_command,
custom_races_status, custom_races_status,
custom_races_install, custom_races_install,
custom_races_uninstall,
custom_races_toggle_client custom_races_toggle_client
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "CoA Server Manager", "productName": "CoA Server Manager",
"version": "0.7.0", "version": "0.6.15",
"identifier": "com.coa.servermanager", "identifier": "com.coa.servermanager",
"build": { "build": {
"beforeDevCommand": "npm run dev", "beforeDevCommand": "npm run dev",
+1
View File
@@ -195,6 +195,7 @@ const de: Partial<Record<keyof typeof en, string>> = {
"comp.saved": "Gespeichert. {n} Begleiter werden beim Serverstart erstellt.", "comp.saved": "Gespeichert. {n} Begleiter werden beim Serverstart erstellt.",
// Client // Client
"client.races.install": "Patch für benutzerdefinierte Völker installieren",
"client.title": "Spielclient", "client.title": "Spielclient",
"client.looking": "Suche …", "client.looking": "Suche …",
"client.intro": "Sag dem Manager, wo dein Spiel installiert ist, um einen SPIELEN-Button zu erhalten. Deine Spieldateien werden nie geändert, außer der Serveradresse und dem Begleiter-Addon.", "client.intro": "Sag dem Manager, wo dein Spiel installiert ist, um einen SPIELEN-Button zu erhalten. Deine Spieldateien werden nie geändert, außer der Serveradresse und dem Begleiter-Addon.",
+1
View File
@@ -238,6 +238,7 @@ const en = {
"comp.saved": "Saved. {n} companions will be created when the server starts.", "comp.saved": "Saved. {n} companions will be created when the server starts.",
// Client // Client
"client.races.install": "Install custom race patch",
"client.title": "Game client", "client.title": "Game client",
"client.looking": "Looking…", "client.looking": "Looking…",
"client.intro": "Tell Manager where your game is installed to get a PLAY button. Your game files are never changed except the server address and the companion addon.", "client.intro": "Tell Manager where your game is installed to get a PLAY button. Your game files are never changed except the server address and the companion addon.",
+1
View File
@@ -195,6 +195,7 @@ const es: Partial<Record<keyof typeof en, string>> = {
"comp.saved": "Guardado. Se crearán {n} compañeros cuando se inicie el servidor.", "comp.saved": "Guardado. Se crearán {n} compañeros cuando se inicie el servidor.",
// Client // Client
"client.races.install": "Instalar parche de razas personalizadas",
"client.title": "Cliente del juego", "client.title": "Cliente del juego",
"client.looking": "Buscando…", "client.looking": "Buscando…",
"client.intro": "Indica al Manager dónde está instalado el juego para obtener un botón JUGAR. Tus archivos del juego nunca se modifican, salvo la dirección del servidor y el addon de compañeros.", "client.intro": "Indica al Manager dónde está instalado el juego para obtener un botón JUGAR. Tus archivos del juego nunca se modifican, salvo la dirección del servidor y el addon de compañeros.",
+1
View File
@@ -195,6 +195,7 @@ const fr: Partial<Record<keyof typeof en, string>> = {
"comp.saved": "Enregistré. {n} compagnons seront créés au démarrage du serveur.", "comp.saved": "Enregistré. {n} compagnons seront créés au démarrage du serveur.",
// Client // Client
"client.races.install": "Installer le patch des races personnalisées",
"client.title": "Client du jeu", "client.title": "Client du jeu",
"client.looking": "Recherche…", "client.looking": "Recherche…",
"client.intro": "Indiquez au Manager où le jeu est installé pour obtenir un bouton JOUER. Vos fichiers de jeu ne sont jamais modifiés, sauf l’adresse du serveur et l’addon des compagnons.", "client.intro": "Indiquez au Manager où le jeu est installé pour obtenir un bouton JOUER. Vos fichiers de jeu ne sont jamais modifiés, sauf l’adresse du serveur et l’addon des compagnons.",
+1
View File
@@ -228,6 +228,7 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"comp.saved": "Сохранено. Компаньоны ({n}) будут созданы при запуске сервера.", "comp.saved": "Сохранено. Компаньоны ({n}) будут созданы при запуске сервера.",
// Client // Client
"client.races.install": "Установить патч кастомных рас",
"client.title": "Клиент игры", "client.title": "Клиент игры",
"client.looking": "Ищу…", "client.looking": "Ищу…",
"client.intro": "Укажите, где установлена игра, чтобы появилась кнопка «Играть». Файлы игры не изменяются, кроме адреса сервера и аддона компаньонов.", "client.intro": "Укажите, где установлена игра, чтобы появилась кнопка «Играть». Файлы игры не изменяются, кроме адреса сервера и аддона компаньонов.",
+1
View File
@@ -207,6 +207,7 @@ const zh = {
"comp.saved": "已保存。{n} 名随从将在服务器启动时创建。", "comp.saved": "已保存。{n} 名随从将在服务器启动时创建。",
// Client // Client
"client.races.install": "安装自定义种族补丁",
"client.title": "游戏客户端", "client.title": "游戏客户端",
"client.looking": "正在寻找…", "client.looking": "正在寻找…",
"client.intro": "指定游戏客户端安装路径即可启用“开始游戏”按钮。除服务器地址和随从插件外,你的游戏文件绝不会被修改。", "client.intro": "指定游戏客户端安装路径即可启用“开始游戏”按钮。除服务器地址和随从插件外,你的游戏文件绝不会被修改。",
+1
View File
@@ -547,6 +547,7 @@ export const api = {
clientDownload: (id: string, parent: string) => invoke<ClientInfo>("client_download", { id, parent }), clientDownload: (id: string, parent: string) => invoke<ClientInfo>("client_download", { id, parent }),
clientCancel: () => invoke<void>("client_cancel"), clientCancel: () => invoke<void>("client_cancel"),
customRacesStatus: (id: string) => invoke<CustomRacesClientStatus | null>("custom_races_status", { id }), customRacesStatus: (id: string) => invoke<CustomRacesClientStatus | null>("custom_races_status", { id }),
customRacesUninstall: (id: string) => invoke<void>("custom_races_uninstall", { id }),
customRacesInstall: (id: string) => invoke<void>("custom_races_install", { id }), customRacesInstall: (id: string) => invoke<void>("custom_races_install", { id }),
customRacesToggleClient: (id: string, enabled: boolean) => invoke<void>("custom_races_toggle_client", { id, enabled }), customRacesToggleClient: (id: string, enabled: boolean) => invoke<void>("custom_races_toggle_client", { id, enabled }),
play: (id: string) => invoke<DriverOutcome>("play", { id }), play: (id: string) => invoke<DriverOutcome>("play", { id }),
+9
View File
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { listen } from "@tauri-apps/api/event";
import { open } from "@tauri-apps/plugin-dialog"; import { open } from "@tauri-apps/plugin-dialog";
import { api, asUiError, type ClientInfo, type ClientStatus, type UiError } from "@/lib/api"; import { api, asUiError, type ClientInfo, type ClientStatus, type UiError } from "@/lib/api";
import { checkClient } from "@/lib/clientUpdate"; import { checkClient } from "@/lib/clientUpdate";
@@ -16,6 +17,7 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
const [note, setNote] = useState<string | null>(null); const [note, setNote] = useState<string | null>(null);
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
const [status, setStatus] = useState<ClientStatus | null>(null); const [status, setStatus] = useState<ClientStatus | null>(null);
const [patchProgress, setPatchProgress] = useState<string | null>(null);
const [dialog, setDialog] = useState<ClientDialogMode | null>(null); const [dialog, setDialog] = useState<ClientDialogMode | null>(null);
const [playAfter, setPlayAfter] = useStartAfterUpdate("client", serverId); const [playAfter, setPlayAfter] = useStartAfterUpdate("client", serverId);
@@ -25,6 +27,10 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
}; };
useEffect(() => { useEffect(() => {
void refresh(); void refresh();
const unlisten = listen<{ id: string; step: string; percent: number }>("custom-races-progress", e => {
if (e.payload.id === serverId) setPatchProgress(`${e.payload.step} (${Math.round(e.payload.percent * 100)}%)`);
});
return () => { void unlisten.then(f => f()); };
}, [serverId]); // eslint-disable-line react-hooks/exhaustive-deps }, [serverId]); // eslint-disable-line react-hooks/exhaustive-deps
async function run(fn: () => Promise<string | void>) { async function run(fn: () => Promise<string | void>) {
@@ -40,6 +46,7 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
setError(asUiError(e)); setError(asUiError(e));
} finally { } finally {
setBusy(false); setBusy(false);
setPatchProgress(null);
} }
} }
@@ -111,11 +118,13 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
{status && !status.managed && ( {status && !status.managed && (
<Button size="sm" disabled={busy} onClick={() => setDialog("track")}>{t("client.track.button")}</Button> <Button size="sm" disabled={busy} onClick={() => setDialog("track")}>{t("client.track.button")}</Button>
)} )}
{remote && <Button size="sm" disabled={busy} onClick={() => void run(() => api.customRacesInstall(serverId))}>{t("client.races.install")}</Button>}
<Button size="sm" variant="ghost" disabled={busy} onClick={() => void choose()}>{t("client.changeFolder")}</Button> <Button size="sm" variant="ghost" disabled={busy} onClick={() => void choose()}>{t("client.changeFolder")}</Button>
<Button size="sm" variant="ghost" disabled={busy} onClick={() => setDialog("setup")}>{t("client.downloadInstead")}</Button> <Button size="sm" variant="ghost" disabled={busy} onClick={() => setDialog("setup")}>{t("client.downloadInstead")}</Button>
</div> </div>
</> </>
)} )}
{patchProgress && <p className="mt-3 text-sm text-muted" role="status">{patchProgress}</p>}
{note && <p className="mt-3 text-sm text-ok" role="status">{note}</p>} {note && <p className="mt-3 text-sm text-ok" role="status">{note}</p>}
{error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>} {error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>}
{dialog && ( {dialog && (
+16 -2
View File
@@ -144,6 +144,17 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
} }
} }
async function uninstallClientPatch() {
setRacesInstalling(true);
setError(null);
try {
await api.customRacesUninstall(serverId);
await load();
onChanged?.();
} catch (e) { setError(asUiError(e)); }
finally { setRacesInstalling(false); }
}
async function toggle(m: ModuleView) { async function toggle(m: ModuleView) {
setError(null); setError(null);
try { try {
@@ -252,7 +263,8 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
</span> </span>
)} )}
</div> </div>
{(!racesPatchStatus || racesPatchStatus.state === "not-installed" || racesPatchStatus.state === "partially-installed") && ( {racesPatchStatus?.state === "partially-installed" && <p className="text-xs text-warn">{locale === "ru" ? "Файлы отсутствуют или изменены. Восстановите патч клиента." : "Files are missing or changed. Repair the client patch."}</p>}
{(
<Button <Button
size="sm" size="sm"
variant="secondary" variant="secondary"
@@ -261,9 +273,11 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
onClick={() => void installClientPatch()} onClick={() => void installClientPatch()}
> >
{racesInstalling && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />} {racesInstalling && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
{locale === "ru" ? "Установить патч клиента" : "Install Client Patch 1.5"} {racesPatchStatus?.state === "not-installed" ? (locale === "ru" ? "Установить патч клиента" : "Install Client Patch") : (locale === "ru" ? "Восстановить патч клиента" : "Repair Client Patch")}
</Button> </Button>
)} )}
{racesPatchStatus && racesPatchStatus.state !== "not-installed" && <Button size="sm" variant="ghost" disabled={racesInstalling} onClick={() => void uninstallClientPatch()}>{locale === "ru" ? "Удалить патч клиента" : "Uninstall Client Patch"}</Button>}
<p className="text-xs text-muted">{locale === "ru" ? (m.enabled ? "После установки патч будет включён." : "После установки патч останется отключённым: модуль сервера выключен или отсутствует.") : (m.enabled ? "The patch will be enabled after installation." : "The patch will stay disabled after installation: the server module is off or missing.")}</p>
</div> </div>
)} )}
</div> </div>