File tree Expand file tree Collapse file tree 3 files changed +22
-18
lines changed
ui/console/command_dispatcher Expand file tree Collapse file tree 3 files changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,10 @@ def load(path, opts = {})
68
68
Kernel . load ( path + ".rb" )
69
69
end
70
70
71
+ # Force unloading if already loaded
72
+ plugin = self . find { |p | p . class == klass }
73
+ unload ( plugin ) if plugin
74
+
71
75
# Create an instance of the plugin and let it initialize
72
76
instance = klass . create ( framework , opts )
73
77
Original file line number Diff line number Diff line change @@ -57,15 +57,16 @@ def rpc_load(path, xopts = {})
57
57
# @example Here's how you would use this from the client:
58
58
# rpc.call('plugin.unload', 'nexpose')
59
59
def rpc_unload ( name )
60
- self . framework . plugins . each { |plugin |
61
- # Unload the plugin if it matches the name we're searching for
62
- if ( plugin . name == name )
63
- self . framework . plugins . unload ( plugin )
64
- return { "result" => "success" }
65
- end
66
- }
67
- return { "result" => "failure" }
60
+ # Find a plugin within the plugins array
61
+ plugin = self . framework . plugins . find { |p | p . name == name }
68
62
63
+ # Unload the plugin if it matches the name we're searching for
64
+ if plugin
65
+ self . framework . plugins . unload ( plugin )
66
+ return { "result" => "success" }
67
+ end
68
+
69
+ return { "result" => "failure" }
69
70
end
70
71
71
72
Original file line number Diff line number Diff line change @@ -1653,16 +1653,15 @@ def cmd_unload(*args)
1653
1653
return false
1654
1654
end
1655
1655
1656
- # Walk the plugins array
1657
- framework . plugins . each { |plugin |
1658
- # Unload the plugin if it matches the name we're searching for
1659
- if ( plugin . name . downcase == args [ 0 ] . downcase )
1660
- print ( "Unloading plugin #{ args [ 0 ] } ..." )
1661
- framework . plugins . unload ( plugin )
1662
- print_line ( "unloaded." )
1663
- break
1664
- end
1665
- }
1656
+ # Find a plugin within the plugins array
1657
+ plugin = framework . plugins . find { |p | p . name . downcase == args [ 0 ] . downcase }
1658
+
1659
+ # Unload the plugin if it matches the name we're searching for
1660
+ if plugin
1661
+ print ( "Unloading plugin #{ args [ 0 ] } ..." )
1662
+ framework . plugins . unload ( plugin )
1663
+ print_line ( "unloaded." )
1664
+ end
1666
1665
end
1667
1666
1668
1667
#
You can’t perform that action at this time.
0 commit comments