Ghidra is a software reverse engineering (SRE) framework
avoid adding duplicate bundles and fix a typo
Jason P. Leasure49998a8235ca
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.javaindex 17a4fcd48a..5b29ece90b 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java@@ -197,13 +197,22 @@ public class BundleHost {* Create new GhidraBundles and add to the list of managed bundles. All GhidraBundles created* with the same {@code enabled} and {@code systemBundle} values.*- * @param bundleFiles a list of bundle files+ * @param bundleFileList a list of bundle files* @param enabled if the new bundle should be enabled* @param systemBundle if the new bundle is a system bundle* @return the new bundle objects*/- public Collection<GhidraBundle> add(List<ResourceFile> bundleFiles, boolean enabled,+ public Collection<GhidraBundle> add(List<ResourceFile> bundleFileList, boolean enabled,boolean systemBundle) {+ Set<ResourceFile> bundleFiles = new HashSet<>(bundleFileList);+ Iterator<ResourceFile> bundleFileIterator = bundleFiles.iterator();+ while (bundleFileIterator.hasNext()) {+ ResourceFile bundleFile = bundleFileIterator.next();+ if (fileToBundleMap.containsKey(bundleFile)) {+ bundleFileIterator.remove();+ Msg.warn(this, "adding an already managed bundle: " + bundleFile.getAbsolutePath());+ }+ }Map<ResourceFile, GhidraBundle> newBundleMap = bundleFiles.stream().collect(Collectors.toUnmodifiableMap(Function.identity(),bundleFile -> createGhidraBundle(BundleHost.this, bundleFile, enabled,diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.javaindex df46dca2b2..95990635b3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java@@ -51,7 +51,7 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {static final String BUNDLE_GROUP = "0bundle group";static final String BUNDLE_LIST_GROUP = "1bundle list group";- static final String PREFENCE_LAST_SELECTED_BUNDLE = "LastGhidraBundle";+ static final String PREFERENCE_LAST_SELECTED_BUNDLE = "LastGhidraBundle";private JPanel panel;private LessFreneticGTable bundleStatusTable;@@ -266,14 +266,14 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {}});}- String lastSelected = Preferences.getProperty(PREFENCE_LAST_SELECTED_BUNDLE);+ String lastSelected = Preferences.getProperty(PREFERENCE_LAST_SELECTED_BUNDLE);if (lastSelected != null) {File lastSelectedFile = new File(lastSelected);fileChooser.setSelectedFile(lastSelectedFile);}}else {- String lastSelected = Preferences.getProperty(PREFENCE_LAST_SELECTED_BUNDLE);+ String lastSelected = Preferences.getProperty(PREFERENCE_LAST_SELECTED_BUNDLE);if (lastSelected != null) {File lastSelectedFile = new File(lastSelected);fileChooser.setSelectedFile(lastSelectedFile);@@ -283,7 +283,7 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {List<File> files = fileChooser.getSelectedFiles();if (!files.isEmpty()) {- Preferences.setProperty(PREFENCE_LAST_SELECTED_BUNDLE, files.get(0).getAbsolutePath());+ Preferences.setProperty(PREFERENCE_LAST_SELECTED_BUNDLE, files.get(0).getAbsolutePath());List<ResourceFile> resourceFiles =files.stream().map(ResourceFile::new).collect(Collectors.toUnmodifiableList());Collection<GhidraBundle> bundles = bundleHost.add(resourceFiles, true, false);