mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #7654 from eugene7646/profiles_NPE_840_DEVELOP
NPE when cancelling profiles creation (8404)
This commit is contained in:
commit
4105a2097f
@ -199,7 +199,7 @@ public final class IngestJobSettings {
|
||||
public Path getSavedModuleSettingsFolder() {
|
||||
return getSavedModuleSettingsFolder(executionContext);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves these ingest job settings.
|
||||
*/
|
||||
|
@ -202,15 +202,24 @@ public final class IngestProfiles {
|
||||
* @param selectedProfile
|
||||
*/
|
||||
synchronized static void deleteProfile(IngestProfile selectedProfile) {
|
||||
deleteProfile(selectedProfile.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all of the files which are currently storing a profile.
|
||||
*
|
||||
* @param profile name
|
||||
*/
|
||||
synchronized static void deleteProfile(String profileName) {
|
||||
try {
|
||||
File rootSettingsFile = getRootSettingsFile(selectedProfile.getName());
|
||||
File settingsDirectory = getSettingsDirectory(selectedProfile.getName());
|
||||
File rootSettingsFile = getRootSettingsFile(profileName);
|
||||
File settingsDirectory = getSettingsDirectory(profileName);
|
||||
Files.deleteIfExists(rootSettingsFile.toPath());
|
||||
FileUtils.deleteDirectory(settingsDirectory);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.WARNING, "Error deleting directory for profile " + selectedProfile.getName(), ex);
|
||||
logger.log(Level.WARNING, "Error deleting directory for profile " + profileName, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames the files and directories associated with a profile
|
||||
|
@ -85,7 +85,15 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||
IngestJobSettings getSettings() {
|
||||
return ingestSettingsPanel.getSettings();
|
||||
}
|
||||
|
||||
|
||||
String getIngestProfileName() {
|
||||
if (profile != null) {
|
||||
return profile.getName();
|
||||
} else {
|
||||
return NEW_PROFILE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
@ -391,7 +391,7 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
*/
|
||||
private void doProfileDialog(IngestProfile selectedProfile) {
|
||||
// Create a files set defintion panel.
|
||||
final AdvancedConfigurationDialog dialog = new AdvancedConfigurationDialog(true);
|
||||
final AdvancedConfigurationDialog dialog = new AdvancedConfigurationDialog(true);
|
||||
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
//start wait cursor for ingest job settings construction
|
||||
if (selectedProfile != null) {
|
||||
@ -430,6 +430,15 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
}
|
||||
panel.saveSettings();
|
||||
load();
|
||||
} else if (option == JOptionPane.CANCEL_OPTION) {
|
||||
if (selectedProfile == null) {
|
||||
// for new profiles, if user canlessed a profile create/edit then delete the temp empty profile that was created.
|
||||
// Otherwise it will remain in "config/ModuleSettings/IngestSettings" and then will get loaded
|
||||
// next time we open ProfilePanel(), causing an NPE (JIRA-8404). This only needs to be done when creating
|
||||
// a new ingest profile. If user cancelled editing of an existing profile, then we should not delete
|
||||
// that profile.
|
||||
IngestProfile.deleteProfile(panel.getIngestProfileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,7 +488,12 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
for (FilesSet fSet : FilesSetsManager.getStandardFileIngestFilters()) {
|
||||
fileIngestFilters.put(fSet.getName(), fSet);
|
||||
}
|
||||
filterDescArea.setText(fileIngestFilters.get(selectedProfile.getFileIngestFilter()).getDescription());
|
||||
String selectedFilter = selectedProfile.getFileIngestFilter();
|
||||
if (selectedFilter == null) {
|
||||
filterDescArea.setText(NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.messages.filterLoadFailed"));
|
||||
} else {
|
||||
filterDescArea.setText(fileIngestFilters.get(selectedFilter).getDescription());
|
||||
}
|
||||
} catch (FilesSetsManager.FilesSetsManagerException ex) {
|
||||
filterDescArea.setText(NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.messages.filterLoadFailed"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user