Compare commits

...
5 changed files with 50 additions and 1 deletions

No files matched your search

@@ -0,0 +1,7 @@
---
area: manager
type: added
audience: admins
title: Module cards show installed server revisions and the client race patch version
---
Module revisions come from the currently installed release metadata. The race card shows the client patch version separately; missing version metadata is reported honestly instead of showing a download version as installed.
+3 -1
View File
@@ -146,6 +146,7 @@ pub enum ClientPatchState {
#[serde(rename_all = "camelCase")]
pub struct ClientPatchStatus {
pub state: ClientPatchState,
pub version: Option<String>,
pub installed_mpqs: usize,
pub total_mpqs: usize,
pub has_root_files: bool,
@@ -210,7 +211,8 @@ pub fn client_patch_status(client_path: &Path) -> ClientPatchStatus {
} 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,
let version = manifest.lines().find_map(|line| line.strip_prefix("# CoA Custom ").map(str::to_string));
ClientPatchStatus { state, version, installed_mpqs, total_mpqs: RACE_MPQS.len(), has_root_files,
client_path: Some(client_path.to_string_lossy().into_owned()) }
}
+37
View File
@@ -119,7 +119,26 @@ fn conf_name(root: &Path, e: &Entry) -> String {
}
}
fn installed_module_commits(root: &Path) -> BTreeMap<String, String> {
let Ok(directory) = crate::registry::metadata_dir_for(root) else { return Default::default() };
let Ok((_, meta)) = crate::registry::MetaDir::open(&directory) else { return Default::default() };
let Some(version) = meta.core.version else { return Default::default() };
let candidates = [directory.join("manifests").join(format!("update-{version}.json")), directory.join("manifests/base.json")];
for path in candidates {
let Ok(manifest) = crate::fsx::read_json::<serde_json::Value>(&path) else { continue };
if manifest.get("version").and_then(|value| value.as_str()) != Some(&version) { continue; }
if let Some(commits) = manifest.get("compatibility").and_then(|value| value.get("moduleCommits")).and_then(|value| value.as_object()) {
return commits.iter().filter_map(|(name, commit)| {
let commit = commit.as_str()?;
(commit.len() == 40 && commit.bytes().all(|byte| byte.is_ascii_hexdigit())).then(|| (name.clone(), commit.chars().take(8).collect()))
}).collect();
}
}
Default::default()
}
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);
cat.iter()
.cloned()
@@ -141,6 +160,8 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
let version = if e.id == "playerbots" { crate::squid::release(root).map(|release| {
[release.tag, release.commit.map(|commit| commit.chars().take(8).collect())].into_iter().flatten().collect::<Vec<_>>().join(" · ")
}) } else { None };
let key = match e.id.as_str() { "companions" => "bots", "playerbots" => "squid", "content-scaling" => "scaling", "custom-races" => "races", id => id };
let version = if installed { version.or_else(|| installed_commits.get(key).cloned()) } else { None };
ModuleView {
version,
compatibility: if blocked { "unsupported" } else if wildcard && e.id != "client-compat" { "experimental" } else { "compatible" }.into(),
@@ -425,6 +446,22 @@ mod tests {
(root, meta)
}
#[test]
fn module_revisions_come_from_the_installed_release_only() {
let temp = tempfile::tempdir().unwrap();
let root = temp.path().join("server");
fs::create_dir_all(&root).unwrap();
let mut meta = crate::registry::InstallMeta::new(crate::registry::InstallKind::Imported, &root);
meta.core.version = Some("2.0.0".into());
let directory = crate::registry::MetaDir::create(&root, &meta).unwrap();
let value = serde_json::json!({"version": "2.0.0", "compatibility": {"moduleCommits": {"races": "a".repeat(40), "bots": "b".repeat(40)}}});
fsx::atomic_write_json(&directory.root.join("manifests/update-2.0.0.json"), &value).unwrap();
assert_eq!(installed_module_commits(&root).get("races").map(String::as_str), Some("aaaaaaaa"));
let stale = serde_json::json!({"version": "1.0.0", "compatibility": {"moduleCommits": {"races": "c".repeat(40)}}});
fsx::atomic_write_json(&directory.root.join("manifests/update-2.0.0.json"), &stale).unwrap();
assert!(installed_module_commits(&root).is_empty());
}
#[test]
fn squid_missing_keys_use_code_defaults_and_saves_enforce_json_ranges() {
let d = tempfile::tempdir().unwrap();
+1
View File
@@ -393,6 +393,7 @@ export interface ClientDownloadCheck {
export type ClientPatchState = "not-installed" | "enabled" | "disabled" | "partially-installed";
export interface CustomRacesClientStatus {
version: string | null;
state: ClientPatchState;
installedMpqs: number;
totalMpqs: number;
+2
View File
@@ -216,7 +216,9 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
{!m.installed && m.status !== "soon" && <span className="mt-1.5 shrink-0 text-xs text-muted">{t("mod.notHere")}</span>}
</div>
{m.id === "custom-races" && (
<div className="w-full">
<p className="text-xs text-muted">{locale === "ru" ? "Установленная версия патча клиента: " : "Installed client patch version: "}{racesPatchStatus?.version ?? (locale === "ru" ? "не записана" : "not recorded")}</p>
{racesInstalling && racesProgress ? (
<div className="rounded-lg border border-gold/30 bg-gold/5 p-3">
<div className="flex items-center justify-between gap-3 text-xs">