@@ -271,6 +271,12 @@ impl PluginManager for CoffeeManager {
271
271
if let Some ( mut plugin) = repo. get_plugin_by_name ( plugin) {
272
272
log:: trace!( "{:?}" , plugin) ;
273
273
274
+ if try_dynamic && plugin. important ( ) {
275
+ return Err ( error ! (
276
+ "plugin is important, can't be dynamically installed"
277
+ ) ) ;
278
+ }
279
+
274
280
// old_root_path is the path where the plugin is cloned and currently stored
275
281
// eg. ~/.coffee/repositories/<repo_name>/<plugin_name>
276
282
let old_root_path = plugin. root_path . clone ( ) ;
@@ -297,6 +303,12 @@ impl PluginManager for CoffeeManager {
297
303
) ;
298
304
let old_exec_path = plugin. exec_path . clone ( ) ;
299
305
306
+ let plugin_conf_key = if plugin. important ( ) {
307
+ "important-plugin"
308
+ } else {
309
+ "plugin"
310
+ } ;
311
+
300
312
match old_exec_path. strip_prefix ( & old_root_path) {
301
313
Some ( relative_path) => {
302
314
let new_exec_path = format ! ( "{}{}" , new_root_path, relative_path) ;
@@ -312,7 +324,7 @@ impl PluginManager for CoffeeManager {
312
324
self . config . plugins . push ( plugin) ;
313
325
log:: debug!( "path coffee conf: {}" , self . coffee_cln_config. path) ;
314
326
self . coffee_cln_config
315
- . add_conf ( "plugin" , & path. to_owned ( ) )
327
+ . add_conf ( plugin_conf_key , & path. to_owned ( ) )
316
328
. map_err ( |err| error ! ( "{}" , err. cause) ) ?;
317
329
log:: debug!( "coffee conf updated: {}" , self . coffee_cln_config) ;
318
330
self . flush ( ) . await ?;
@@ -348,9 +360,14 @@ impl PluginManager for CoffeeManager {
348
360
log:: debug!( "runnable plugin path: {exec_path}" ) ;
349
361
plugins. remove ( index) ;
350
362
log:: debug!( "coffee cln config: {}" , self . coffee_cln_config) ;
363
+ let plugin_conf_key = if plugin. important ( ) {
364
+ "important-plugin"
365
+ } else {
366
+ "plugin"
367
+ } ;
351
368
let remove_config = self
352
369
. coffee_cln_config
353
- . rm_conf ( "plugin" , Some ( & exec_path. to_owned ( ) ) ) ;
370
+ . rm_conf ( plugin_conf_key , Some ( & exec_path. to_owned ( ) ) ) ;
354
371
if let Err ( err) = remove_config {
355
372
// if this is true, we are probably a dynamic plugin:
356
373
if err. cause . contains ( "field with `plugin` not present" ) {
0 commit comments