@@ -253,6 +253,12 @@ impl PluginManager for CoffeeManager {
253
253
if let Some ( mut plugin) = repo. get_plugin_by_name ( plugin) {
254
254
log:: trace!( "{:?}" , plugin) ;
255
255
256
+ if try_dynamic && plugin. important ( ) {
257
+ return Err ( error ! (
258
+ "plugin is important, can't be dynamically installed"
259
+ ) ) ;
260
+ }
261
+
256
262
// old_root_path is the path where the plugin is cloned and currently stored
257
263
// eg. ~/.coffee/repositories/<repo_name>/<plugin_name>
258
264
let old_root_path = plugin. root_path . clone ( ) ;
@@ -279,6 +285,12 @@ impl PluginManager for CoffeeManager {
279
285
) ;
280
286
let old_exec_path = plugin. exec_path . clone ( ) ;
281
287
288
+ let plugin_conf_key = if plugin. important ( ) {
289
+ "important-plugin"
290
+ } else {
291
+ "plugin"
292
+ } ;
293
+
282
294
match old_exec_path. strip_prefix ( & old_root_path) {
283
295
Some ( relative_path) => {
284
296
let new_exec_path = format ! ( "{}{}" , new_root_path, relative_path) ;
@@ -294,7 +306,7 @@ impl PluginManager for CoffeeManager {
294
306
self . config . plugins . push ( plugin) ;
295
307
log:: debug!( "path coffee conf: {}" , self . coffee_cln_config. path) ;
296
308
self . coffee_cln_config
297
- . add_conf ( "plugin" , & path. to_owned ( ) )
309
+ . add_conf ( plugin_conf_key , & path. to_owned ( ) )
298
310
. map_err ( |err| error ! ( "{}" , err. cause) ) ?;
299
311
log:: debug!( "coffee conf updated: {}" , self . coffee_cln_config) ;
300
312
self . flush ( ) . await ?;
@@ -328,8 +340,13 @@ impl PluginManager for CoffeeManager {
328
340
log:: debug!( "runnable plugin path: {exec_path}" ) ;
329
341
plugins. remove ( index) ;
330
342
log:: debug!( "coffee cln config: {}" , self . coffee_cln_config) ;
343
+ let plugin_conf_key = if plugin. important ( ) {
344
+ "important-plugin"
345
+ } else {
346
+ "plugin"
347
+ } ;
331
348
self . coffee_cln_config
332
- . rm_conf ( "plugin" , Some ( & exec_path. to_owned ( ) ) )
349
+ . rm_conf ( plugin_conf_key , Some ( & exec_path. to_owned ( ) ) )
333
350
. map_err ( |err| error ! ( "{}" , & err. cause) ) ?;
334
351
self . flush ( ) . await ?;
335
352
self . update_conf ( ) . await ?;
0 commit comments