style: format merged codebase and update release artifact hashes

This commit is contained in:
Дмитрий committed 2026-10-10 08:09:50 +05:00
1 parent 2b95553168
commit e035f33fc0
17 files changed
+685 -170

No files matched your search

+3 -4
View File
@@ -269,8 +269,7 @@ pub(crate) async fn join_realm(
let caps = serde_json::to_value(&detail.capabilities)
.map_err(|e| fail("other", e.to_string()))?;
let id = character.clone();
let pre = portable
.call(move |s| s.preflight_advert(&id, &caps))??;
let pre = portable.call(move |s| s.preflight_advert(&id, &caps))??;
out.notes = pre.notes.clone();
if pre.step == portable_service::Step::Blocked {
ch.close();
@@ -281,8 +280,8 @@ pub(crate) async fn join_realm(
if !here.iter().any(|(id, _)| id.to_string() == character) {
// Phase 12.1: Transfer canonical character to remote Host over the encrypted control channel
let char_id_str = character.clone();
let bundle = portable
.call(move |s| s.export_for_remote_transfer(&char_id_str))??;
let bundle =
portable.call(move |s| s.export_for_remote_transfer(&char_id_str))??;
let cuuid = bundle.character_id.as_uuid();
let _outcome = pc
.transfer_character(
+77 -17
View File
@@ -28,32 +28,58 @@ pub fn default_dir() -> String {
}
fn default_dir_in(home: Option<&str>) -> String {
match home.map(|h| h.trim_end_matches('/')).filter(|h| !h.is_empty()) {
match home
.map(|h| h.trim_end_matches('/'))
.filter(|h| !h.is_empty())
{
Some(h) => format!("{h}/CoaServer"),
None => "/srv/coa".into(),
}
}
pub fn docker_problem() -> Option<String> {
docker::check_docker(&SystemDocker).err().map(|e| e.to_string())
docker::check_docker(&SystemDocker)
.err()
.map(|e| e.to_string())
}
pub fn environment() -> Environment {
Environment { flavor: coa_core::platform::flavor(), default_dir: default_dir(), docker_problem: docker_problem() }
Environment {
flavor: coa_core::platform::flavor(),
default_dir: default_dir(),
docker_problem: docker_problem(),
}
}
pub fn preflight(dest: &str, data: Option<String>, needed: Option<u64>, registry: &Registry) -> Preflight {
pub fn preflight(
dest: &str,
data: Option<String>,
needed: Option<u64>,
registry: &Registry,
) -> Preflight {
// The size comes from the signed package list when the screen already has it; it is checked again at install time.
core_install::preflight(Path::new(dest), Path::new(data.as_deref().unwrap_or("")), needed.unwrap_or(1024 * 1024 * 1024), registry)
core_install::preflight(
Path::new(dest),
Path::new(data.as_deref().unwrap_or("")),
needed.unwrap_or(1024 * 1024 * 1024),
registry,
)
}
/// The Linux package has no default address yet: it is published only after the maintainer has signed it.
pub fn package_source(custom: Option<String>) -> Result<Source> {
let pick = custom.filter(|s| !s.trim().is_empty()).or_else(|| std::env::var("COA_PACKAGE_SOURCE").ok().filter(|s| !s.trim().is_empty()));
let pick = custom.filter(|s| !s.trim().is_empty()).or_else(|| {
std::env::var("COA_PACKAGE_SOURCE")
.ok()
.filter(|s| !s.trim().is_empty())
});
match pick {
Some(p) if p.to_ascii_lowercase().starts_with("http") => Ok(Source::Url(p)),
Some(p) => Ok(Source::Dir(PathBuf::from(p))),
None => Err(Error::Invalid("Choose the Linux server package (a folder or an address): none is published yet.".into())),
None => Err(Error::Invalid(
"Choose the Linux server package (a folder or an address): none is published yet."
.into(),
)),
}
}
@@ -69,26 +95,54 @@ pub fn trusted_key() -> String {
coa_core::signing::EMBEDDED_PUBLIC_KEY.to_string()
}
pub async fn requirements(package: Option<String>) -> std::result::Result<InstallRequirements, UiError> {
pub async fn requirements(
package: Option<String>,
) -> std::result::Result<InstallRequirements, UiError> {
blocking(move || {
let (m, _) = coa_core::pkgsource::fetch_manifest(&package_source(package)?, &trusted_key())?;
let archive = m.archive.ok_or_else(|| Error::InvalidManifest("no archive".into()))?;
Ok(InstallRequirements { download_bytes: archive.parts.iter().map(|p| p.size).sum(), unpacked_bytes: archive.unpacked_size, version: m.version })
let (m, _) =
coa_core::pkgsource::fetch_manifest(&package_source(package)?, &trusted_key())?;
let archive = m
.archive
.ok_or_else(|| Error::InvalidManifest("no archive".into()))?;
Ok(InstallRequirements {
download_bytes: archive.parts.iter().map(|p| p.size).sum(),
unpacked_bytes: archive.unpacked_size,
version: m.version,
})
})
.await
}
pub async fn install(app: AppHandle, state: State<'_, AppState>, dest: String, package: Option<String>, data: Option<String>) -> std::result::Result<ServerSummary, UiError> {
pub async fn install(
app: AppHandle,
state: State<'_, AppState>,
dest: String,
package: Option<String>,
data: Option<String>,
) -> std::result::Result<ServerSummary, UiError> {
let source = package_source(package)?;
let data_dir_path = PathBuf::from(data.filter(|d| !d.trim().is_empty()).ok_or_else(|| Error::Invalid("Choose the folder that holds the game data.".into()))?);
let data_dir_path = PathBuf::from(
data.filter(|d| !d.trim().is_empty())
.ok_or_else(|| Error::Invalid("Choose the folder that holds the game data.".into()))?,
);
let cancel = Cancel::default();
*state.install_cancel.lock().map_err(|_| Error::Invalid("state poisoned".into()))? = Some(cancel.clone());
*state
.install_cancel
.lock()
.map_err(|_| Error::Invalid("state poisoned".into()))? = Some(cancel.clone());
let registry = Registry::at(data_dir().join("installs.json"));
let dest_path = PathBuf::from(dest);
let key = trusted_key();
let result = tauri::async_runtime::spawn_blocking(move || {
core_install::install(
&core_install::Params { source, dest: dest_path, data_dir: data_dir_path, trusted_key: &key, registry: &registry, cancel },
&core_install::Params {
source,
dest: dest_path,
data_dir: data_dir_path,
trusted_key: &key,
registry: &registry,
cancel,
},
&|step| {
let _ = app.emit("install-progress", step);
},
@@ -119,7 +173,13 @@ mod tests {
std::env::remove_var("COA_PACKAGE_SOURCE");
assert!(package_source(None).is_err());
assert!(package_source(Some(" ".into())).is_err());
assert!(matches!(package_source(Some("/tmp/pkg".into())).unwrap(), Source::Dir(_)));
assert!(matches!(package_source(Some("https://example.org/pkg".into())).unwrap(), Source::Url(_)));
assert!(matches!(
package_source(Some("/tmp/pkg".into())).unwrap(),
Source::Dir(_)
));
assert!(matches!(
package_source(Some("https://example.org/pkg".into())).unwrap(),
Source::Url(_)
));
}
}
+46 -15
View File
@@ -11,10 +11,10 @@ use coa_core::backup::{self, Kind, RecoveryPoint, Trigger, VerifyReport};
use coa_core::config::{self, Scope, SettingsView};
use coa_core::download::Cancel;
use coa_core::driver::{self, DriverOutcome, Verb};
use coa_core::platform::{self, Flavor};
use coa_core::error::UiError;
use coa_core::install::{self, Preflight, Source};
use coa_core::layout::{self, Classification, ScanReport};
use coa_core::platform::{self, Flavor};
use coa_core::portable::service::{self as portable_service, PortableRuntime, ServiceError};
use coa_core::process::{self, Observed};
use coa_core::ra::Ra;
@@ -341,7 +341,13 @@ fn default_install_dir() -> String {
/// whether Docker can be used.
#[tauri::command]
async fn install_environment() -> docker_install::Environment {
tauri::async_runtime::spawn_blocking(docker_install::environment).await.unwrap_or_else(|_| docker_install::Environment { flavor: platform::flavor(), default_dir: default_install_dir(), docker_problem: None })
tauri::async_runtime::spawn_blocking(docker_install::environment)
.await
.unwrap_or_else(|_| docker_install::Environment {
flavor: platform::flavor(),
default_dir: default_install_dir(),
docker_problem: None,
})
}
#[tauri::command]
@@ -827,7 +833,12 @@ async fn restore_backup_database(
}
#[tauri::command]
fn install_preflight(state: State<'_, AppState>, dest: String, needed: Option<u64>, game_data: Option<String>) -> Preflight {
fn install_preflight(
state: State<'_, AppState>,
dest: String,
needed: Option<u64>,
game_data: Option<String>,
) -> Preflight {
if platform::flavor() == Flavor::Docker {
return docker_install::preflight(&dest, game_data, needed, &state.registry);
}
@@ -1137,31 +1148,46 @@ async fn module_set_enabled(
}
#[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)?;
blocking(move || {
let client = linked_client(&root)?;
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
}
#[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 _guard = BusyGuard::acquire(&state, &id)?;
let cancel = begin_client_job(&state)?;
let sid = id.clone();
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 = linked_client(&root)?
.ok_or_else(|| Error::Invalid("No game client is linked to this server.".into()))?;
coa_core::custom_races::install_client_patches(&client, &cancel, &|step, percent| {
let _ = app.emit("custom-races-progress", serde_json::json!({
"id": sid,
"step": step,
"percent": percent,
}));
let _ = app.emit(
"custom-races-progress",
serde_json::json!({
"id": sid,
"step": step,
"percent": percent,
}),
);
})?;
let enabled = coa_core::modules::list(&root).iter().any(|module| module.id == "custom-races" && module.enabled);
let enabled = coa_core::modules::list(&root)
.iter()
.any(|module| module.id == "custom-races" && module.enabled);
coa_core::custom_races::set_client_patch_enabled(&client, enabled)
})
.await;
@@ -1170,11 +1196,16 @@ async fn custom_races_install(app: AppHandle, state: State<'_, AppState>, id: St
}
#[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 _guard = BusyGuard::acquire(&state, &id)?;
blocking(move || {
let client = linked_client(&root)?.ok_or_else(|| Error::Invalid("No game client is linked to this server.".into()))?;
let client = linked_client(&root)?
.ok_or_else(|| Error::Invalid("No game client is linked to this server.".into()))?;
coa_core::custom_races::set_client_patch_enabled(&client, enabled)
})
.await