script info manager should only "find" info it has

This commit is contained in:
Jason P. Leasure 2020-04-29 15:35:27 -04:00
parent 04a16aa0f4
commit 4911e0814a
2 changed files with 7 additions and 12 deletions

View file

@ -109,7 +109,7 @@ class GhidraScriptActionManager {
void restoreScriptsThatAreInTool(SaveState saveState) {
String[] array = saveState.getStrings(SCRIPT_ACTIONS_KEY, new String[0]);
for (String filename : array) {
ScriptInfo info = infoManager.findScriptByName(filename);
ScriptInfo info = infoManager.findScriptInfoByName(filename);
if (info != null) { // the file may have been deleted from disk
provider.getActionManager().createAction(info.getSourceFile());
}

View file

@ -168,26 +168,21 @@ public class GhidraScriptInfoManager {
* limitation that all script names in Ghidra must be unique. If the given name has multiple
* script matches, then a warning will be logged.
*
* @param name The name for which to find a script
* @param scriptName The name for which to find a script
* @return The ScriptInfo that has the given name
*/
public ScriptInfo findScriptByName(String name) {
List<ResourceFile> matchingFiles = scriptNameToFilesMap.get(name);
public ScriptInfo findScriptInfoByName(String scriptName) {
List<ResourceFile> matchingFiles = scriptNameToFilesMap.get(scriptName);
if (matchingFiles != null && !matchingFiles.isEmpty()) {
ScriptInfo info = scriptFileToInfoMap.get(matchingFiles.get(0));
if (matchingFiles.size() > 1) {
Msg.warn(GhidraScriptInfoManager.class, "Found duplicate scripts for name: " +
name + ". Binding to script: " + info.getSourceFile());
scriptName + ". Binding to script: " + info.getSourceFile());
}
return info;
}
ResourceFile file = GhidraScriptUtil.findScriptFileInPaths(
GhidraScriptUtil.getBundleHost().getBundlePaths(), name);
if (file == null) {
return null;
}
return getExistingScriptInfo(file); // this will cache the created info
// don't search in paths
return null;
}
}