@@ -157,7 +157,7 @@ extract_schema(#plugin{type = dir, location = Location}, SchemaDir) ->
157
157
158
158
% % @doc Lists the plugins which are currently running.
159
159
active () ->
160
- InstalledPlugins = plugin_names (list (plugins_expand_dir ())),
160
+ InstalledPlugins = plugin_names (list (plugins_dist_dir ())),
161
161
[App || {App , _ , _ } <- rabbit_misc :which_applications (),
162
162
lists :member (App , InstalledPlugins )].
163
163
@@ -280,10 +280,8 @@ prepare_plugins(Enabled) ->
280
280
{error , E2 } -> throw ({error , {cannot_create_plugins_expand_dir ,
281
281
[ExpandDir , E2 ]}})
282
282
end ,
283
- [prepare_plugin (Plugin , ExpandDir ) || Plugin <- ValidPlugins ],
284
283
285
- [prepare_dir_plugin (PluginAppDescPath ) ||
286
- PluginAppDescPath <- filelib :wildcard (ExpandDir ++ " /*/ebin/*.app" )],
284
+ [prepare_plugin (Plugin , ExpandDir ) || Plugin <- ValidPlugins ],
287
285
Wanted .
288
286
289
287
maybe_warn_about_invalid_plugins ([]) ->
@@ -460,11 +458,37 @@ delete_recursively(Fn) ->
460
458
{error , {Path , E }} -> {error , {cannot_delete , Path , E }}
461
459
end .
462
460
463
- prepare_plugin (# plugin {type = ez , location = Location }, ExpandDir ) ->
464
- zip :unzip (Location , [{cwd , ExpandDir }]);
465
- prepare_plugin (# plugin {type = dir , name = Name , location = Location },
466
- ExpandDir ) ->
467
- rabbit_file :recursive_copy (Location , filename :join ([ExpandDir , Name ])).
461
+ find_unzipped_app_file (ExpandDir , Files ) ->
462
+ StripComponents = length (filename :split (ExpandDir )),
463
+ [ X || X <- Files ,
464
+ [_AppName , " ebin" , MaybeAppFile ] <-
465
+ [lists :nthtail (StripComponents , filename :split (X ))],
466
+ lists :suffix (" .app" , MaybeAppFile )
467
+ ].
468
+
469
+ prepare_plugin (# plugin {type = ez , name = Name , location = Location }, ExpandDir ) ->
470
+ case zip :unzip (Location , [{cwd , ExpandDir }]) of
471
+ {ok , Files } ->
472
+ case find_unzipped_app_file (ExpandDir , Files ) of
473
+ [PluginAppDescPath |_ ] ->
474
+ prepare_dir_plugin (PluginAppDescPath );
475
+ _ ->
476
+ rabbit_log :error (" Plugin archive '~s ' doesn't contain .app file~n " , [Location ]),
477
+ throw ({no_plugin_app_file_in_archive , Name , Location })
478
+ end ;
479
+ {error , Reason } ->
480
+ rabbit_log :error (" Plugin archive '~s ' unpacking failed: ~p~n " , [Location , Reason ]),
481
+ throw ({plugin_unpack_failed , Name , Location , Reason })
482
+ end ;
483
+ prepare_plugin (# plugin {type = dir , location = Location , name = Name },
484
+ _ExpandDir ) ->
485
+ case filelib :wildcard (Location ++ " /ebin/*.app" ) of
486
+ [PluginAppDescPath |_ ] ->
487
+ prepare_dir_plugin (PluginAppDescPath );
488
+ _ ->
489
+ rabbit_log :error (" Plugin directory '~s ' doesn't contain an .app file~n " , [Location ]),
490
+ throw ({no_plugin_app_file_in_directory , Name , Location })
491
+ end .
468
492
469
493
plugin_info ({ez , EZ }) ->
470
494
case read_app_file (EZ ) of
0 commit comments