From 6972d8059e07768b08d6587b08660f5e8e618125 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro <gregd@basistech.com> Date: Thu, 19 May 2022 18:41:58 -0400 Subject: [PATCH] bug fixes --- .../centralrepository/eventlisteners/Installer.java | 12 ++++++++++-- Core/src/org/sleuthkit/autopsy/ingest/Installer.java | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java index 8af515156b..f5f35ccc0e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java @@ -47,7 +47,8 @@ */ 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_MODULE_SETTINGS_KEY = "CentralRepository"; @@ -104,8 +105,15 @@ private void upgradeSettingsPath() { if (!newSettingsFile.exists() && legacySettingsFile.exists()) { Map<String, String> prevSettings = ModuleSettings.getConfigSettings(LEGACY_MODULE_SETTINGS_KEY); 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 (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()); File prevDir = new File(prevPath); // copy all files starting with prevDbName in prevPath to new path location. diff --git a/Core/src/org/sleuthkit/autopsy/ingest/Installer.java b/Core/src/org/sleuthkit/autopsy/ingest/Installer.java index 3f6aa4802e..19fa852b20 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/Installer.java @@ -97,7 +97,8 @@ private void upgradeSettings() { .filter(e -> e.getKey() != null) .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()); } catch (IOException ex) { -- GitLab