diff options
| author | Aram Drevekenin <aram@poor.dev> | 2023-11-30 18:10:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-30 18:10:50 +0100 |
| commit | b0f36540fe3cb439fd0981cbb1ef5df6668ddbdf (patch) | |
| tree | 6d1d7329361ad25506cc7e1cb7ea135b9434191b /zellij-server/src/plugins/plugin_loader.rs | |
| parent | chore(version): bump development version (diff) | |
| download | sl0ppij-b0f36540fe3cb439fd0981cbb1ef5df6668ddbdf.tar.gz sl0ppij-b0f36540fe3cb439fd0981cbb1ef5df6668ddbdf.tar.xz sl0ppij-b0f36540fe3cb439fd0981cbb1ef5df6668ddbdf.zip | |
feat(plugins): skip plugin cache flag (#2971)
* feat(plugins): allow explicitly skipping the plugin cache when loading
* style(fmt): rustfmt
* fix tests
Diffstat (limited to 'zellij-server/src/plugins/plugin_loader.rs')
| -rw-r--r-- | zellij-server/src/plugins/plugin_loader.rs | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/zellij-server/src/plugins/plugin_loader.rs b/zellij-server/src/plugins/plugin_loader.rs index 39cb4362..1f001db1 100644 --- a/zellij-server/src/plugins/plugin_loader.rs +++ b/zellij-server/src/plugins/plugin_loader.rs @@ -148,6 +148,7 @@ impl<'a> PluginLoader<'a> { client_attributes: ClientAttributes, default_shell: Option<TerminalAction>, default_layout: Box<Layout>, + skip_cache: bool, ) -> Result<()> { let err_context = || format!("failed to start plugin {plugin_id} for client {client_id}"); let mut plugin_loader = PluginLoader::new( @@ -168,27 +169,49 @@ impl<'a> PluginLoader<'a> { default_shell, default_layout, )?; - plugin_loader - .load_module_from_memory() - .or_else(|_e| plugin_loader.load_module_from_hd_cache()) - .or_else(|_e| plugin_loader.compile_module()) - .and_then(|module| plugin_loader.create_plugin_environment(module)) - .and_then(|(store, instance, plugin_env, subscriptions)| { - plugin_loader.load_plugin_instance( - store, - &instance, - &plugin_env, - &plugin_map, - &subscriptions, - ) - }) - .and_then(|_| { - plugin_loader.clone_instance_for_other_clients( - &connected_clients.lock().unwrap(), - &plugin_map, - ) - }) - .with_context(err_context)?; + if skip_cache { + plugin_loader + .compile_module() + .and_then(|module| plugin_loader.create_plugin_environment(module)) + .and_then(|(store, instance, plugin_env, subscriptions)| { + plugin_loader.load_plugin_instance( + store, + &instance, + &plugin_env, + &plugin_map, + &subscriptions, + ) + }) + .and_then(|_| { + plugin_loader.clone_instance_for_other_clients( + &connected_clients.lock().unwrap(), + &plugin_map, + ) + }) + .with_context(err_context)?; + } else { + plugin_loader + .load_module_from_memory() + .or_else(|_e| plugin_loader.load_module_from_hd_cache()) + .or_else(|_e| plugin_loader.compile_module()) + .and_then(|module| plugin_loader.create_plugin_environment(module)) + .and_then(|(store, instance, plugin_env, subscriptions)| { + plugin_loader.load_plugin_instance( + store, + &instance, + &plugin_env, + &plugin_map, + &subscriptions, + ) + }) + .and_then(|_| { + plugin_loader.clone_instance_for_other_clients( + &connected_clients.lock().unwrap(), + &plugin_map, + ) + }) + .with_context(err_context)?; + }; display_loading_stage!(end, loading_indication, senders, plugin_id); Ok(()) } |
