feat: commit code

This commit is contained in:
YuKun Liu committed 2022-10-08 21:28:06 -07:00
1 parent f238e43bff
commit cf9a9513df
2 files changed
+12 -11

No files matched your search

View File
Whitespace-only changes.
+12 -11
View File
@@ -33,11 +33,6 @@ impl PluginManager {
pub fn init(config: toml::Value) -> anyhow::Result<()> { pub fn init(config: toml::Value) -> anyhow::Result<()> {
let lua = LUA.lock().unwrap(); let lua = LUA.lock().unwrap();
if !config.is_table() {
// if plugins config is not a table, then termination init
return Ok(());
}
let manager = lua.create_table().unwrap(); let manager = lua.create_table().unwrap();
let plugin_dir = Self::init_plugin_dir(); let plugin_dir = Self::init_plugin_dir();
@@ -55,6 +50,8 @@ impl PluginManager {
lua.globals() lua.globals()
.set("library_dir", plugin_dir.to_str().unwrap()) .set("library_dir", plugin_dir.to_str().unwrap())
.unwrap(); .unwrap();
// lua.globals()
// .set("config_info", );
let mut index: u32 = 1; let mut index: u32 = 1;
let mut init_list: Vec<(u32, PathBuf, PluginInfo)> = Vec::new(); let mut init_list: Vec<(u32, PathBuf, PluginInfo)> = Vec::new();
@@ -122,16 +119,20 @@ impl PluginManager {
} }
Ok(false) => { Ok(false) => {
log::warn!("Plugin init function result is `false`, init failed."); log::warn!("Plugin init function result is `false`, init failed.");
let _ = lua.load(mlua::chunk! { let _ = lua
table.remove(manager, $idx) .load(mlua::chunk! {
}).exec(); table.remove(manager, $idx)
})
.exec();
} }
Err(e) => { Err(e) => {
// plugin init failed // plugin init failed
log::warn!("Plugin init failed: {e}"); log::warn!("Plugin init failed: {e}");
let _ = lua.load(mlua::chunk! { let _ = lua
table.remove(manager, $idx) .load(mlua::chunk! {
}).exec(); table.remove(manager, $idx)
})
.exec();
} }
} }
} }