@@ -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
@@ -213,8 +213,7 @@ strictly_plugins(Plugins, AllPlugins) ->
213
213
end , Plugins ).
214
214
215
215
strictly_plugins (Plugins ) ->
216
- ExpandDir = plugins_expand_dir (),
217
- AllPlugins = list (ExpandDir ),
216
+ AllPlugins = list (plugins_dist_dir ()),
218
217
lists :filter (
219
218
fun (Name ) ->
220
219
is_strictly_plugin (lists :keyfind (Name , # plugin .name , AllPlugins ))
@@ -280,10 +279,8 @@ prepare_plugins(Enabled) ->
280
279
{error , E2 } -> throw ({error , {cannot_create_plugins_expand_dir ,
281
280
[ExpandDir , E2 ]}})
282
281
end ,
283
- [prepare_plugin (Plugin , ExpandDir ) || Plugin <- ValidPlugins ],
284
282
285
- [prepare_dir_plugin (PluginAppDescPath ) ||
286
- PluginAppDescPath <- filelib :wildcard (ExpandDir ++ " /*/ebin/*.app" )],
283
+ [prepare_plugin (Plugin , ExpandDir ) || Plugin <- ValidPlugins ],
287
284
Wanted .
288
285
289
286
maybe_warn_about_invalid_plugins ([]) ->
@@ -460,11 +457,37 @@ delete_recursively(Fn) ->
460
457
{error , {Path , E }} -> {error , {cannot_delete , Path , E }}
461
458
end .
462
459
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 ])).
460
+ find_unzipped_app_file (ExpandDir , Files ) ->
461
+ StripComponents = length (filename :split (ExpandDir )),
462
+ [ X || X <- Files ,
463
+ [_AppName , " ebin" , MaybeAppFile ] <-
464
+ [lists :nthtail (StripComponents , filename :split (X ))],
465
+ lists :suffix (" .app" , MaybeAppFile )
466
+ ].
467
+
468
+ prepare_plugin (# plugin {type = ez , name = Name , location = Location }, ExpandDir ) ->
469
+ case zip :unzip (Location , [{cwd , ExpandDir }]) of
470
+ {ok , Files } ->
471
+ case find_unzipped_app_file (ExpandDir , Files ) of
472
+ [PluginAppDescPath |_ ] ->
473
+ prepare_dir_plugin (PluginAppDescPath );
474
+ _ ->
475
+ rabbit_log :error (" Plugin archive '~s ' doesn't contain an .app file~n " , [Location ]),
476
+ throw ({app_file_missing , Name , Location })
477
+ end ;
478
+ {error , Reason } ->
479
+ rabbit_log :error (" Could not unzip plugin archive '~s ': ~p~n " , [Location , Reason ]),
480
+ throw ({failed_to_unzip_plugin , Name , Location , Reason })
481
+ end ;
482
+ prepare_plugin (# plugin {type = dir , location = Location , name = Name },
483
+ _ExpandDir ) ->
484
+ case filelib :wildcard (Location ++ " /ebin/*.app" ) of
485
+ [PluginAppDescPath |_ ] ->
486
+ prepare_dir_plugin (PluginAppDescPath );
487
+ _ ->
488
+ rabbit_log :error (" Plugin directory '~s ' doesn't contain an .app file~n " , [Location ]),
489
+ throw ({app_file_missing , Name , Location })
490
+ end .
468
491
469
492
plugin_info ({ez , EZ }) ->
470
493
case read_app_file (EZ ) of
0 commit comments