mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 19:25:56 +00:00
preview: compressed module build cache with a clear dialog; module sources without client files
- Build cache (build_cache.rs): the build folder of a module is unpacked for a build and packed into <module>.tar.zst afterwards (object files ~4-6x smaller), modification times kept so Ninja recompiles only what changed. A cache made for another core is dropped instead of unpacked; .ilk and .map files are not kept; total limit 2 GB, least recently built first. The build log moves next to the archive (build-cache/<module>.log). - "Build cache" in the Modules menu: size per module (packed, built when, for this core or not), remove one, remove all, remove downloaded sources. Builds now hold the server's busy guard, so the cache is never cleared under a running build. - Module sources: "Add from a link" downloads GitHub's archive of the commit instead of a full git clone, and game-client files (.mpq, .dbc, maps, textures, archives) are left out and listed in .coa_skipped_assets. mod-bg-battle-for-gilneas: 365 MB repository, 3.1 MB kept (was refused at the 300 MB limit). - Overlay: Helias's battleground modules (Gilneas, Twin Peaks, Slavery Valley) are Incompatible: they need the server's DBC files replaced (CoA ships its own) and a client patch. Checked: build_cache unit tests; examples/build_cache_ninja_check with real MSVC + CMake + Ninja: after pack/unpack nothing is recompiled, after one edit one file is; coa-core lib tests 865 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3987f1b2ff
commit
899b7c6617
12 files changed
+705
-5
No files matched your search
@@ -3083,6 +3083,42 @@ async fn analyze_github_module(
|
||||
.await
|
||||
}
|
||||
|
||||
/// What the module build cache of a server (and the shared source downloads) take on disk.
|
||||
#[tauri::command]
|
||||
async fn build_cache_summary(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
) -> std::result::Result<coa_core::build_cache::CacheSummary, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
let sources = data_dir().join("github_cache");
|
||||
blocking(move || Ok(coa_core::build_cache::summary(&root, Some(&sources)))).await
|
||||
}
|
||||
|
||||
/// Remove the build cache of one module (`module`), of all modules (no `module`), and optionally the downloaded
|
||||
/// sources. Refused while a build runs on this server. Returns the bytes freed.
|
||||
#[tauri::command]
|
||||
async fn build_cache_clear(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
module: Option<String>,
|
||||
sources: bool,
|
||||
) -> std::result::Result<u64, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
let _guard = BusyGuard::acquire(&state, &id)?;
|
||||
let sources_dir = data_dir().join("github_cache");
|
||||
blocking(move || {
|
||||
let mut freed = 0;
|
||||
if module.is_some() || !sources {
|
||||
freed += coa_core::build_cache::clear(&root, module.as_deref())?;
|
||||
}
|
||||
if sources {
|
||||
freed += coa_core::build_cache::clear_sources(&sources_dir)?;
|
||||
}
|
||||
Ok(freed)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_public_module_catalog(
|
||||
force_refresh: Option<bool>,
|
||||
@@ -3131,6 +3167,8 @@ async fn preview_build_module(
|
||||
|
||||
let realm_root = path_of(&state, &realm_id)?;
|
||||
let cache_dir = data_dir().join("github_cache");
|
||||
// The build works in the module's build cache: clearing the cache waits for it.
|
||||
let _guard = BusyGuard::acquire(&state, &realm_id)?;
|
||||
|
||||
let app_clone = app.clone();
|
||||
let progress_cb: Box<dyn Fn(coa_core::build_engine::BuildProgressEvent) + Send + Sync> =
|
||||
@@ -3594,6 +3632,8 @@ pub fn run() {
|
||||
account_delete,
|
||||
install_new,
|
||||
is_classic_server,
|
||||
build_cache_summary,
|
||||
build_cache_clear,
|
||||
cancel_install,
|
||||
create_account,
|
||||
check_update,
|
||||
|
||||
Reference in new issue
Block a user