From 2317d46bdaf8cc0e57c5c80474705684174e3bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 1 Oct 2026 07:56:40 +0500 Subject: [PATCH] Client updates never overwrite renderer wrappers or config files; test that nothing outside the manifest changes Co-Authored-By: Claude Sonnet 5.5 --- crates/coa-core/src/clientdl.rs | 54 +++++++++++++++++++++++++++++++++ src/i18n/locales/de.ts | 2 +- src/i18n/locales/en.ts | 2 +- src/i18n/locales/es.ts | 2 +- src/i18n/locales/fr.ts | 2 +- src/i18n/locales/ru.ts | 2 +- 6 files changed, 59 insertions(+), 5 deletions(-) diff --git a/crates/coa-core/src/clientdl.rs b/crates/coa-core/src/clientdl.rs index f6ca7be..a63eed3 100644 --- a/crates/coa-core/src/clientdl.rs +++ b/crates/coa-core/src/clientdl.rs @@ -68,6 +68,14 @@ fn is_excluded(path: &str) -> bool { || p.starts_with("interface/addons/coabotui/") } +/// Files players customise: graphics wrappers and their configuration. If one exists and differs from the published +/// file it is left exactly as it is, whatever the "keep my files" choice; it is only created when missing. +fn is_player_owned(path: &str) -> bool { + let name = path.rsplit('/').next().unwrap_or(path).to_ascii_lowercase(); + matches!(name.as_str(), "d3d8.dll" | "d3d9.dll" | "d3d10core.dll" | "d3d11.dll" | "dxgi.dll" | "dxvk.conf") + || matches!(name.rsplit('.').next(), Some("ini" | "conf" | "cfg" | "wtf")) +} + pub fn parse_manifest(text: &str) -> Result { let raw: RawManifest = serde_json::from_str(text).map_err(|e| Error::Invalid(format!("The client list could not be read: {e}")))?; if raw.schema != 1 { @@ -264,6 +272,15 @@ pub fn plan(client: &Path, m: &Manifest, state: &State, cancel: &Cancel, on_step None }; done += f.size; + if is_player_owned(&f.path) && local.as_deref() != Some(f.sha256.as_str()) { + let sha = match local { + Some(h) => h, + None => hash_file(&path, cancel, &mut |_| {})?, + }; + kept += 1; + confirmed.insert(f.path.clone(), Entry { size, mtime, sha256: sha, kept_against: Some(f.sha256.clone()) }); + continue; + } if local.as_deref() == Some(f.sha256.as_str()) { up_to_date += 1; confirmed.insert(f.path.clone(), Entry { size, mtime, sha256: f.sha256.clone(), kept_against: None }); @@ -520,6 +537,43 @@ mod tests { assert_eq!(fs::read(saved.join("Wow.exe")).unwrap(), b"my patched exe", "the player's version was moved aside, not lost"); } + #[test] + fn renderer_files_configs_and_everything_not_in_the_manifest_survive_an_update_untouched() { + let d = tempfile::tempdir().unwrap(); + let v1: Vec<(&str, &[u8])> = vec![("Wow.exe", b"exe-1"), ("d3d9.dll", b"official d3d9"), ("dxvk.conf", b"official conf"), ("Data/common.MPQ", b"common-1")]; + sync(d.path(), &manifest("v1", &v1), &Server::new(&v1), false).unwrap(); + // the player's own setup: custom renderer + configs, addons, WTF, realmlist, extra archives, backups + let mine: Vec<(&str, &[u8])> = vec![ + ("d3d9.dll", b"my renderer"), + ("dxvk.conf", b"my conf"), + ("ModernWoWRenderer.ini", b"cfg"), + ("GraphicsEffects.ini.bak", b"bak"), + ("Data/enUS/realmlist.wtf", b"set realmlist 127.0.0.1 +"), + ("Data/patch-5.MPQ", b"extra archive"), + ("Interface/AddOns/ElvUI/ElvUI.toc", b"## Title: Elv"), + ("WTF/Account/x/SavedVariables.lua", b"vars"), + ("Cache/x.wdb", b"cache"), + ]; + for (p, b) in &mine { + let path = d.path().join(p); + fs::create_dir_all(path.parent().unwrap()).unwrap(); + fs::write(path, b).unwrap(); + } + let before: BTreeMap = mine.iter().map(|(p, b)| (p.to_string(), fsx::sha256_bytes(b))).collect(); + let v2: Vec<(&str, &[u8])> = vec![("Wow.exe", b"exe-2"), ("d3d9.dll", b"official d3d9 v2"), ("dxvk.conf", b"official conf v2"), ("Data/common.MPQ", b"common-2")]; + let (m2, s2) = (manifest("v2", &v2), Server::new(&v2)); + for keep in [false, true] { + sync(d.path(), &m2, &s2, keep).unwrap(); + for (p, h) in &before { + assert_eq!(&fsx::sha256_file(&d.path().join(p)).unwrap(), h, "{p} must not change (keep_modified={keep})"); + } + assert_eq!(fs::read(d.path().join("Wow.exe")).unwrap(), b"exe-2"); + assert_eq!(fs::read(d.path().join("Data/common.MPQ")).unwrap(), b"common-2"); + } + assert!(!d.path().join(".coa-manager/replaced").exists(), "nothing of the player's was displaced"); + } + #[test] fn an_existing_client_without_state_is_compared_by_content() { let d = tempfile::tempdir().unwrap(); diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index 8aa30a7..a692e71 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -610,7 +610,7 @@ const de: Partial> = { "client.upd.summary": "{n} Datei(en) zum Herunterladen, insgesamt {size}.", "client.upd.upToDate": "Dein Client entspricht bereits Version {v}.", "client.upd.modifiedTitle": "{n} Datei(en) hast du geändert", - "client.upd.modifiedText": "Zum Beispiel eine eigene d3d9.dll oder eine gepatchte Programmdatei. Behalte sie oder ersetze sie durch die offiziellen Versionen; deine werden dann im Ordner .coa-manager des Clients gesichert.", + "client.upd.modifiedText": "Zum Beispiel eine gepatchte Programmdatei. Behalte sie oder ersetze sie durch die offiziellen Versionen; deine werden dann im Ordner .coa-manager des Clients gesichert. Grafik-Wrapper (d3d9.dll und ähnliche) und Konfigurationsdateien bleiben immer unverändert.", "client.upd.keep": "Von mir geänderte Dateien behalten", "client.upd.more": "… und {n} weitere", "client.upd.start": "Client aktualisieren", diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index a5470ba..9b619ea 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -610,7 +610,7 @@ const en = { "client.upd.summary": "{n} file(s) to download, {size} in total.", "client.upd.upToDate": "Your client already matches version {v}.", "client.upd.modifiedTitle": "{n} file(s) were changed by you", - "client.upd.modifiedText": "For example a custom d3d9.dll or a patched executable. Keep them, or replace them with the official versions; yours are then saved in the client’s .coa-manager folder.", + "client.upd.modifiedText": "For example a patched executable. Keep them, or replace them with the official versions; yours are then saved in the client’s .coa-manager folder. Graphics wrappers (d3d9.dll and the like) and config files are always left as they are.", "client.upd.keep": "Keep the files I changed", "client.upd.more": "… and {n} more", "client.upd.start": "Update client", diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index f88bbea..e22b3ce 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -610,7 +610,7 @@ const es: Partial> = { "client.upd.summary": "{n} archivo(s) por descargar, {size} en total.", "client.upd.upToDate": "Tu cliente ya coincide con la versión {v}.", "client.upd.modifiedTitle": "{n} archivo(s) cambiado(s) por ti", - "client.upd.modifiedText": "Por ejemplo un d3d9.dll personalizado o un ejecutable modificado. Consérvalos o reemplázalos por las versiones oficiales; los tuyos se guardan entonces en la carpeta .coa-manager del cliente.", + "client.upd.modifiedText": "Por ejemplo un ejecutable modificado. Consérvalos o reemplázalos por las versiones oficiales; los tuyos se guardan entonces en la carpeta .coa-manager del cliente. Los wrappers gráficos (d3d9.dll y similares) y los archivos de configuración se dejan siempre como están.", "client.upd.keep": "Conservar los archivos que cambié", "client.upd.more": "… y {n} más", "client.upd.start": "Actualizar cliente", diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index ff589a4..3b4205b 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -610,7 +610,7 @@ const fr: Partial> = { "client.upd.summary": "{n} fichier(s) à télécharger, {size} au total.", "client.upd.upToDate": "Votre client correspond déjà à la version {v}.", "client.upd.modifiedTitle": "{n} fichier(s) modifié(s) par vous", - "client.upd.modifiedText": "Par exemple un d3d9.dll personnalisé ou un exécutable modifié. Conservez-les ou remplacez-les par les versions officielles ; les vôtres sont alors sauvegardées dans le dossier .coa-manager du client.", + "client.upd.modifiedText": "Par exemple un exécutable modifié. Conservez-les ou remplacez-les par les versions officielles ; les vôtres sont alors sauvegardées dans le dossier .coa-manager du client. Les wrappers graphiques (d3d9.dll et similaires) et les fichiers de configuration restent toujours tels quels.", "client.upd.keep": "Conserver les fichiers que j’ai modifiés", "client.upd.more": "… et {n} de plus", "client.upd.start": "Mettre à jour le client", diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index e72867f..98a25c8 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -610,7 +610,7 @@ const ru: Partial> = { "client.upd.summary": "Файлов к загрузке: {n}, всего {size}.", "client.upd.upToDate": "Ваш клиент уже соответствует версии {v}.", "client.upd.modifiedTitle": "Файлов, изменённых вами: {n}", - "client.upd.modifiedText": "Например, свой d3d9.dll или изменённый exe. Оставьте их или замените официальными версиями; ваши тогда сохранятся в папке .coa-manager внутри клиента.", + "client.upd.modifiedText": "Например, изменённый exe. Оставьте их или замените официальными версиями; ваши тогда сохранятся в папке .coa-manager внутри клиента. Графические обёртки (d3d9.dll и подобные) и конфиги всегда остаются как есть.", "client.upd.keep": "Оставить файлы, которые я менял", "client.upd.more": "… и ещё {n}", "client.upd.start": "Обновить клиент",