@@ -103,7 +103,7 @@ setup() ->
103
103
104
104
% % @doc Lists the plugins which are currently running.
105
105
active () ->
106
- InstalledPlugins = plugin_names (list (plugins_expand_dir ())),
106
+ InstalledPlugins = plugin_names (list (plugins_dist_dir ())),
107
107
[App || {App , _ , _ } <- rabbit_misc :which_applications (),
108
108
lists :member (App , InstalledPlugins )].
109
109
@@ -200,9 +200,6 @@ prepare_plugins(Enabled) ->
200
200
end ,
201
201
202
202
[prepare_plugin (Plugin , ExpandDir ) || Plugin <- WantedPlugins ],
203
-
204
- [prepare_dir_plugin (PluginAppDescPath ) ||
205
- PluginAppDescPath <- filelib :wildcard (ExpandDir ++ " /*/ebin/*.app" )],
206
203
Wanted .
207
204
208
205
clean_plugins (Plugins ) ->
@@ -250,11 +247,37 @@ delete_recursively(Fn) ->
250
247
{error , {Path , E }} -> {error , {cannot_delete , Path , E }}
251
248
end .
252
249
253
- prepare_plugin (# plugin {type = ez , location = Location }, ExpandDir ) ->
254
- zip :unzip (Location , [{cwd , ExpandDir }]);
255
- prepare_plugin (# plugin {type = dir , name = Name , location = Location },
256
- ExpandDir ) ->
257
- rabbit_file :recursive_copy (Location , filename :join ([ExpandDir , Name ])).
250
+ find_unzipped_app_file (ExpandDir , Files ) ->
251
+ StripComponents = length (filename :split (ExpandDir )),
252
+ [ X || X <- Files ,
253
+ [_AppName , " ebin" , MaybeAppFile ] <-
254
+ [lists :nthtail (StripComponents , filename :split (X ))],
255
+ lists :suffix (" .app" , MaybeAppFile )
256
+ ].
257
+
258
+ prepare_plugin (# plugin {type = ez , name = Name , location = Location }, ExpandDir ) ->
259
+ case zip :unzip (Location , [{cwd , ExpandDir }]) of
260
+ {ok , Files } ->
261
+ case find_unzipped_app_file (ExpandDir , Files ) of
262
+ [PluginAppDescPath |_ ] ->
263
+ prepare_dir_plugin (PluginAppDescPath );
264
+ _ ->
265
+ rabbit_log :error (" Plugin archive '~s ' doesn't contain an .app file~n " , [Location ]),
266
+ throw ({app_file_missing , Name , Location })
267
+ end ;
268
+ {error , Reason } ->
269
+ rabbit_log :error (" Could not unzip plugin archive '~s ': ~p~n " , [Location , Reason ]),
270
+ throw ({failed_to_unzip_plugin , Name , Location , Reason })
271
+ end ;
272
+ prepare_plugin (# plugin {type = dir , location = Location , name = Name },
273
+ _ExpandDir ) ->
274
+ case filelib :wildcard (Location ++ " /ebin/*.app" ) of
275
+ [PluginAppDescPath |_ ] ->
276
+ prepare_dir_plugin (PluginAppDescPath );
277
+ _ ->
278
+ rabbit_log :error (" Plugin directory '~s ' doesn't contain an .app file~n " , [Location ]),
279
+ throw ({app_file_missing , Name , Location })
280
+ end .
258
281
259
282
plugin_info ({ez , EZ }) ->
260
283
case read_app_file (EZ ) of
0 commit comments