lib/kpm/installer.rb in kpm-0.2.0 vs lib/kpm/installer.rb in kpm-0.2.1

- old
+ new

@@ -37,10 +37,11 @@ install_killbill_server(@config['group_id'], @config['artifact_id'], @config['packaging'], @config['classifier'], @config['version'], @config['webapp_path'], force_download, verify_sha1) install_plugins(force_download, verify_sha1) unless @config['default_bundles'] == false install_default_bundles(@config['plugins_dir'], @config['default_bundles_version'], @config['version'], force_download, verify_sha1) end + clean_up_descriptors end unless @kaui_config.nil? if @kaui_config['webapp_path'].nil? @logger.warn('No webapp_path specified for Kaui, aborting installation') @@ -97,7 +98,45 @@ verify_jruby_jar=false end infos end + + def clean_up_descriptors + removed_plugins = clean_up_plugin_identifiers + clean_up_sha1s(removed_plugins) + end + + def clean_up_plugin_identifiers + inspector = KPM::Inspector.new + installed_plugins = inspector.inspect(@config['plugins_dir']) + + plugins_installation_path = File.join(@config['plugins_dir'], 'plugins') + plugins_manager = KPM::PluginsManager.new(plugins_installation_path, @logger) + + plugin_identifiers = plugins_manager.read_plugin_identifiers + removed_identifiers = [] + plugin_identifiers.each do |plugin_key, plugin| + if !installed_plugins.has_key?(plugin['plugin_name']) + _, plugin_entry = plugins_manager.get_identifier_key_and_entry(plugin_key) + plugins_manager.remove_plugin_identifier_key(plugin_key) + removed_identifiers << plugin_entry + end + end + + removed_identifiers + end + + def clean_up_sha1s(removed_plugins) + sha1checker = KPM::Sha1Checker.from_file(File.join(@config['plugins_dir'], KPM::BaseInstaller::SHA1_FILENAME)) + removed_plugins.each do |removed| + coordinates = KPM::Coordinates.build_coordinates(group_id: removed['group_id'], + artifact_id: removed['artifact_id'], + packaging: removed['packaging'], + classifier: removed['classifier'], + version: removed['version']) + sha1checker.remove_entry!(coordinates) + end + end + end end