mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Fix PR comments. Use thread.join to wait for AddMultipleImageTask thread.
This commit is contained in:
parent
b08f4a7119
commit
9db0cf2b7e
@ -72,9 +72,10 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
private final Case currentCase;
|
private final Case currentCase;
|
||||||
|
|
||||||
private volatile boolean cancelled;
|
private volatile boolean cancelled;
|
||||||
private boolean addingInterestingFiles;
|
private volatile boolean addingInterestingFiles;
|
||||||
private AddMultipleImageTask addMultipleImageTask;
|
private AddMultipleImageTask addMultipleImageTask;
|
||||||
private boolean createVHD;
|
private Thread multipleImageThread;
|
||||||
|
private volatile boolean createVHD;
|
||||||
private long totalFiles;
|
private long totalFiles;
|
||||||
private Map<String, Long> imagePathToObjIdMap;
|
private Map<String, Long> imagePathToObjIdMap;
|
||||||
|
|
||||||
@ -183,7 +184,8 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddDataSourceCallback privateCallback = null;
|
addMultipleImageTask = null;
|
||||||
|
AddDataSourceCallback privateCallback = new AddDataSourceCallback();
|
||||||
List<Content> newDataSources = new ArrayList<>();
|
List<Content> newDataSources = new ArrayList<>();
|
||||||
|
|
||||||
if (imagePaths.isEmpty()) {
|
if (imagePaths.isEmpty()) {
|
||||||
@ -213,13 +215,14 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
createVHD = true;
|
createVHD = true;
|
||||||
// ingest the VHDs
|
// ingest the VHDs
|
||||||
try {
|
try {
|
||||||
privateCallback = new AddDataSourceCallback();
|
|
||||||
addMultipleImageTask = new AddMultipleImageTask(deviceId, imagePaths, timeZone , progressMonitor, privateCallback);
|
addMultipleImageTask = new AddMultipleImageTask(deviceId, imagePaths, timeZone , progressMonitor, privateCallback);
|
||||||
addMultipleImageTask.run();
|
multipleImageThread = new Thread(addMultipleImageTask);
|
||||||
if (privateCallback.getResult() == DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS) {
|
multipleImageThread.start();
|
||||||
// TODO: Delete destination directory when 5453 (VHD file is not closed upon revert) is fixed.
|
try {
|
||||||
// bait out
|
multipleImageThread.join();
|
||||||
callback.done(privateCallback.getResult(), privateCallback.getErrorMessages(), privateCallback.getNewDataSources());
|
} catch (InterruptedException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Add Image interrupted", ex); // NON-NLS
|
||||||
|
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errorList, emptyDataSources);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (NoCurrentCaseException ex) {
|
} catch (NoCurrentCaseException ex) {
|
||||||
@ -235,7 +238,7 @@ final class AddLogicalImageTask implements Runnable {
|
|||||||
addingInterestingFiles = true;
|
addingInterestingFiles = true;
|
||||||
addInterestingFiles(Paths.get(dest.toString(), resultsFilename), createVHD);
|
addInterestingFiles(Paths.get(dest.toString(), resultsFilename), createVHD);
|
||||||
progressMonitor.setProgressText(Bundle.AddLogicalImageTask_doneAddingInterestingFiles());
|
progressMonitor.setProgressText(Bundle.AddLogicalImageTask_doneAddingInterestingFiles());
|
||||||
if (addMultipleImageTask != null && privateCallback != null) {
|
if (createVHD) {
|
||||||
callback.done(privateCallback.getResult(), privateCallback.getErrorMessages(), privateCallback.getNewDataSources());
|
callback.done(privateCallback.getResult(), privateCallback.getErrorMessages(), privateCallback.getNewDataSources());
|
||||||
} else {
|
} else {
|
||||||
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS, errorList, newDataSources);
|
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS, errorList, newDataSources);
|
||||||
|
@ -213,14 +213,15 @@ class AddMultipleImageTask implements Runnable {
|
|||||||
tskAddImageProcessStopped = true;
|
tskAddImageProcessStopped = true;
|
||||||
if (addImageProcess != null) {
|
if (addImageProcess != null) {
|
||||||
try {
|
try {
|
||||||
|
/*
|
||||||
|
* All this does is set a flag that will make the TSK add
|
||||||
|
* image process exit when the flag is checked between
|
||||||
|
* processing steps. The state of the flag is not
|
||||||
|
* accessible, so record it here so that it is known that
|
||||||
|
* the revert method of the process object needs to be
|
||||||
|
* called.
|
||||||
|
*/
|
||||||
addImageProcess.stop();
|
addImageProcess.stop();
|
||||||
addImageProcess.revert();
|
|
||||||
if (tskAddImageProcessStopped) {
|
|
||||||
List<String> errorMessages = new ArrayList<>();
|
|
||||||
List<Content> emptyDataSources = new ArrayList<>();
|
|
||||||
errorMessages.add(Bundle.AddMultipleImageTask_cancelled());
|
|
||||||
callback.done(DataSourceProcessorResult.CRITICAL_ERRORS, errorMessages, emptyDataSources);
|
|
||||||
}
|
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Cancellation: addImagePRocess.stop failed", ex); // NON-NLS
|
LOGGER.log(Level.SEVERE, "Cancellation: addImagePRocess.stop failed", ex); // NON-NLS
|
||||||
}
|
}
|
||||||
@ -295,7 +296,6 @@ class AddMultipleImageTask implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tskAddImageProcessStopped) {
|
|
||||||
/*
|
/*
|
||||||
* Try to commit the results of the add image process, retrieve the new
|
* Try to commit the results of the add image process, retrieve the new
|
||||||
* image from the case database, and add it to the list of new data
|
* image from the case database, and add it to the list of new data
|
||||||
@ -326,4 +326,3 @@ class AddMultipleImageTask implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -36,6 +36,7 @@ import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
|||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
|
||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
|
||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.TimeStampUtils;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,7 +174,7 @@ public final class LogicalImagerDSProcessor implements DataSourceProcessor {
|
|||||||
JOptionPane.YES_NO_OPTION);
|
JOptionPane.YES_NO_OPTION);
|
||||||
if (showConfirmDialog == YES_OPTION) {
|
if (showConfirmDialog == YES_OPTION) {
|
||||||
// Get unique dest directory
|
// Get unique dest directory
|
||||||
String uniqueDirectory = imageDirPath.getFileName() + "_" + UUID.randomUUID();
|
String uniqueDirectory = imageDirPath.getFileName() + "_" + TimeStampUtils.createTimeStamp();
|
||||||
dest = Paths.get(logicalImagerDir.toString(), uniqueDirectory).toFile();
|
dest = Paths.get(logicalImagerDir.toString(), uniqueDirectory).toFile();
|
||||||
} else {
|
} else {
|
||||||
String msg = Bundle.LogicalImagerDSProcessor_directoryAlreadyExists(dest.toString());
|
String msg = Bundle.LogicalImagerDSProcessor_directoryAlreadyExists(dest.toString());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user