From d2d3590d28e8144770c0d49c8e20e089eaae2b47 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Mon, 5 May 2025 12:23:30 -0400 Subject: [PATCH] GP-5633: Fixed a bug that prevented new installations of Ghidra from applying preferences found in older installed versions of Ghidra --- .../java/ghidra/framework/GenericRunInfo.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/GenericRunInfo.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/GenericRunInfo.java index f0b92588e3..7c62561fd6 100644 --- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/GenericRunInfo.java +++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/GenericRunInfo.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,15 +47,15 @@ public class GenericRunInfo { File userSettingsDirectory = Application.getUserSettingsDirectory(); List appDirs = - collectAllApplicationDirectories(userSettingsDirectory.getParentFile()); + collectAllApplicationDirectories(userSettingsDirectory.getParentFile(), false); // Search "legacy" user setting directory locations in case the user has upgraded from an // older version try { File legacyUserSettingsDirectory = ApplicationUtilities.getLegacyUserSettingsDir( layout.getApplicationProperties(), layout.getApplicationInstallationDir()); - appDirs.addAll( - collectAllApplicationDirectories(legacyUserSettingsDirectory.getParentFile())); + appDirs.addAll(collectAllApplicationDirectories( + legacyUserSettingsDirectory.getParentFile(), true)); } catch (FileNotFoundException e) { // ignore @@ -92,9 +92,11 @@ public class GenericRunInfo { return appDirs; } - private static List collectAllApplicationDirectories(File dataDirectoryParentDir) { + private static List collectAllApplicationDirectories(File dataDirectoryParentDir, + boolean legacy) { - String settingsDirPrefix = "." + Application.getName().replaceAll("\\s", "").toLowerCase(); + String appName = Application.getName().replaceAll("\\s", "").toLowerCase(); + String settingsDirPrefix = (legacy ? "." : "") + appName; FileFilter userDirFilter = f -> { String name = f.getName(); return f.isDirectory() && name.startsWith(settingsDirPrefix) &&