mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 11:25:56 +00:00
fix(modules-preview): isolate dll detection, deduplicate plugins, fix toggle exclusivity and metadata resolution
This commit is contained in:
1 parent
221f4a93d3
commit
c2bf8ecbb6
4 files changed
+99
-19
No files matched your search
@@ -259,7 +259,25 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
})
|
||||
});
|
||||
|
||||
let dll_candidates = [
|
||||
let alias_dlls: Vec<PathBuf> = match e.id.as_str() {
|
||||
"content-scaling" => vec![
|
||||
root.join("plugins").join("coa-content-scaling").join("coa-content-scaling.dll"),
|
||||
root.join("plugins").join("coa-content-scaling.dll"),
|
||||
],
|
||||
"companions" => vec![
|
||||
root.join("plugins").join("coa-playerbots").join("coa-playerbots.dll"),
|
||||
root.join("plugins").join("coa-playerbots.dll"),
|
||||
root.join("plugins").join("mod-coa-playerbots.dll"),
|
||||
],
|
||||
"playerbots" => vec![
|
||||
root.join("plugins").join("mod-playerbots").join("mod-playerbots.dll"),
|
||||
root.join("plugins").join("squid-playerbots").join("squid-playerbots.dll"),
|
||||
root.join("plugins").join("mod-playerbots.dll"),
|
||||
],
|
||||
_ => Vec::new(),
|
||||
};
|
||||
|
||||
let mut dll_candidates = vec![
|
||||
root.join("plugins").join(format!("{}.dll", e.id)),
|
||||
root.join("plugins").join(format!("{}.dll", e.id.replace('-', "_"))),
|
||||
root.join("plugins").join(format!("coa-{}.dll", e.id)),
|
||||
@@ -273,14 +291,12 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
root.join("plugins").join(format!("coa-{}", e.id)).join(format!("coa-{}.dll", e.id)),
|
||||
root.join("plugins").join(format!("mod-{}", e.id)).join(format!("mod-{}.dll", e.id)),
|
||||
root.join("plugins").join(format!("mod-coa-{}", e.id)).join(format!("mod-coa-{}.dll", e.id)),
|
||||
// Special alias subdirectories
|
||||
root.join("plugins").join("coa-content-scaling").join("coa-content-scaling.dll"),
|
||||
root.join("plugins").join("coa-playerbots").join("coa-playerbots.dll"),
|
||||
// .manager/plugins checks
|
||||
root.join(".manager/plugins").join(format!("{}.dll", e.id)),
|
||||
root.join(".manager/plugins").join(format!("coa-{}.dll", e.id)),
|
||||
root.join(".manager/plugins").join(format!("mod-coa-{}.dll", e.id)),
|
||||
];
|
||||
dll_candidates.extend(alias_dlls);
|
||||
let dll_present = dll_candidates.iter().any(|p| p.is_file());
|
||||
let is_dynamic = plugin_entry.is_some() || dll_present;
|
||||
|
||||
@@ -427,7 +443,16 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
// Also include installed dynamic plugins from plugin_reg that aren't already in views
|
||||
if let Some(ref reg) = plugin_reg {
|
||||
for (plugin_id, plugin_entry) in ®.plugins {
|
||||
if !views.iter().any(|v| v.id == *plugin_id) {
|
||||
let is_already_represented = views.iter().any(|v| {
|
||||
v.id == *plugin_id
|
||||
|| format!("coa-{}", v.id) == *plugin_id
|
||||
|| format!("mod-coa-{}", v.id) == *plugin_id
|
||||
|| format!("mod-{}", v.id) == *plugin_id
|
||||
|| (v.id == "content-scaling" && matches!(plugin_id.as_str(), "coa-content-scaling" | "mod-coa-content-scaling"))
|
||||
|| (v.id == "companions" && matches!(plugin_id.as_str(), "coa-playerbots" | "mod-coa-playerbots"))
|
||||
|| (v.id == "playerbots" && matches!(plugin_id.as_str(), "squid-playerbots" | "mod-playerbots"))
|
||||
});
|
||||
if !is_already_represented {
|
||||
let mut display_name = if let Ok(meta) = crate::plugins::load_store_metadata(root, plugin_id, &plugin_entry.sha256) {
|
||||
meta.name
|
||||
} else {
|
||||
|
||||
@@ -949,9 +949,21 @@ pub fn update(
|
||||
pub fn remove(server: &Path, id: &str) -> Result<()> {
|
||||
require_server_stopped(server)?;
|
||||
|
||||
let mut tx = TxGuard::begin_op(server, PluginOpType::Remove, id)?;
|
||||
let mut reg = load_registry_direct(server)?;
|
||||
if reg.plugins.remove(id).is_none() {
|
||||
let actual_id = if reg.plugins.contains_key(id) {
|
||||
id.to_string()
|
||||
} else if reg.plugins.contains_key(&format!("coa-{}", id)) {
|
||||
format!("coa-{}", id)
|
||||
} else if reg.plugins.contains_key(&format!("mod-{}", id)) {
|
||||
format!("mod-{}", id)
|
||||
} else if reg.plugins.contains_key(&format!("mod-coa-{}", id)) {
|
||||
format!("mod-coa-{}", id)
|
||||
} else {
|
||||
id.to_string()
|
||||
};
|
||||
|
||||
let mut tx = TxGuard::begin_op(server, PluginOpType::Remove, &actual_id)?;
|
||||
if reg.plugins.remove(&actual_id).is_none() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -962,10 +974,14 @@ pub fn remove(server: &Path, id: &str) -> Result<()> {
|
||||
regenerate_lockfile(server, ®)?;
|
||||
check_crash_injection("after_lock_update");
|
||||
|
||||
let target_dir = plugins_install_dir(server).join(id);
|
||||
let target_dir = plugins_install_dir(server).join(&actual_id);
|
||||
if target_dir.is_dir() {
|
||||
let _ = fs::remove_dir_all(target_dir);
|
||||
}
|
||||
let flat_dll = plugins_install_dir(server).join(format!("{}.dll", actual_id));
|
||||
if flat_dll.is_file() {
|
||||
let _ = fs::remove_file(flat_dll);
|
||||
}
|
||||
|
||||
tx.set_phase(TransactionPhase::Validating)?;
|
||||
check_crash_injection("before_commit");
|
||||
|
||||
Reference in new issue
Block a user