Skip to content
Snippets Groups Projects
Commit 6972d805 authored by Greg DiCristofaro's avatar Greg DiCristofaro
Browse files

bug fixes

parent 0aada857
No related branches found
No related tags found
No related merge requests found
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
*/ */
public class Installer extends ModuleInstall { public class Installer extends ModuleInstall {
private static final String LEGACY_DEFAULT_DB_PARENT_PATH = Paths.get(PlatformUtil.getUserDirectory().getAbsolutePath(), "central_repository").toAbsolutePath().toString(); private static final String LEGACY_DEFAULT_FOLDER = "central_repository";
private static final String LEGACY_DEFAULT_DB_PARENT_PATH = Paths.get(PlatformUtil.getUserDirectory().getAbsolutePath(), LEGACY_DEFAULT_FOLDER).toAbsolutePath().toString();
//private static final String LEGACY_DEFAULT_DB_NAME = "central_repository.db"; //private static final String LEGACY_DEFAULT_DB_NAME = "central_repository.db";
private static final String LEGACY_MODULE_SETTINGS_KEY = "CentralRepository"; private static final String LEGACY_MODULE_SETTINGS_KEY = "CentralRepository";
...@@ -104,8 +105,15 @@ private void upgradeSettingsPath() { ...@@ -104,8 +105,15 @@ private void upgradeSettingsPath() {
if (!newSettingsFile.exists() && legacySettingsFile.exists()) { if (!newSettingsFile.exists() && legacySettingsFile.exists()) {
Map<String, String> prevSettings = ModuleSettings.getConfigSettings(LEGACY_MODULE_SETTINGS_KEY); Map<String, String> prevSettings = ModuleSettings.getConfigSettings(LEGACY_MODULE_SETTINGS_KEY);
String prevPath = prevSettings.get(SqliteCentralRepoSettings.getDatabasePathKey()); String prevPath = prevSettings.get(SqliteCentralRepoSettings.getDatabasePathKey());
File prevDirCheck = new File(prevPath);
// if a relative directory, make sure it is relative to user config.
if (!prevDirCheck.isAbsolute()) {
prevPath = Paths.get(PlatformUtil.getUserDirectory().getAbsolutePath(), prevPath).toAbsolutePath().toString();
}
// if old path is default path for sqlite db, copy it over to new location and update setting. // if old path is default path for sqlite db, copy it over to new location and update setting.
if (prevPath != null && Paths.get(LEGACY_DEFAULT_DB_PARENT_PATH).equals(Paths.get(prevPath).toAbsolutePath())) { if (prevPath != null
&& Paths.get(LEGACY_DEFAULT_DB_PARENT_PATH).toAbsolutePath().toString().equals(Paths.get(prevPath).toAbsolutePath().toString())) {
String prevDbName = prevSettings.get(SqliteCentralRepoSettings.getDatabaseNameKey()); String prevDbName = prevSettings.get(SqliteCentralRepoSettings.getDatabaseNameKey());
File prevDir = new File(prevPath); File prevDir = new File(prevPath);
// copy all files starting with prevDbName in prevPath to new path location. // copy all files starting with prevDbName in prevPath to new path location.
......
...@@ -97,7 +97,8 @@ private void upgradeSettings() { ...@@ -97,7 +97,8 @@ private void upgradeSettings() {
.filter(e -> e.getKey() != null) .filter(e -> e.getKey() != null)
.collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue() == null ? null : e.getValue().toString(), (v1, v2) -> v1)); .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue() == null ? null : e.getValue().toString(), (v1, v2) -> v1));
ModuleSettings.setConfigSettings(IngestJobSettings.getModuleSettingsResource(settingsName), moduleSettingsToSave); String resourceName = isProfile ? IngestProfiles.getExecutionContext(settingsName) : settingsName;
ModuleSettings.setConfigSettings(IngestJobSettings.getModuleSettingsResource(resourceName), moduleSettingsToSave);
FileUtils.copyDirectory(moduleSettingsFolder, IngestJobSettings.getSavedModuleSettingsFolder(settingsName).toFile()); FileUtils.copyDirectory(moduleSettingsFolder, IngestJobSettings.getSavedModuleSettingsFolder(settingsName).toFile());
} catch (IOException ex) { } catch (IOException ex) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment