diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestJob.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestJob.java index 667d20fa58..5023ff0cfb 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestJob.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestJob.java @@ -65,13 +65,12 @@ final class IngestJob { long jobId = nextIngestJobId.incrementAndGet(); IngestJob job = new IngestJob(jobId, dataSource, ingestModuleTemplates, processUnallocatedSpace); ingestJobsById.put(jobId, job); - IngestManager.getInstance().fireIngestJobStarted(jobId); List errors = job.start(); if (errors.isEmpty()) { + IngestManager.getInstance().fireIngestJobStarted(jobId); taskScheduler.scheduleTasksForIngestJob(job, dataSource); } else { ingestJobsById.remove(jobId); - IngestManager.getInstance().fireIngestJobCancelled(jobId); } return errors; } @@ -106,7 +105,7 @@ final class IngestJob { return processUnallocatedSpace; } - List start() throws InterruptedException { + private List start() throws InterruptedException { List errors = startUpIngestPipelines(); if (errors.isEmpty()) { startFileIngestProgressBar(); @@ -180,24 +179,26 @@ final class IngestJob { } void process(DataSourceIngestTask task) throws InterruptedException { - // If the job is not cancelled, complete the task, otherwise just flush - // it. if (!isCancelled()) { List errors = new ArrayList<>(); errors.addAll(dataSourceIngestPipeline.process(task.getDataSource(), dataSourceTasksProgress)); if (!errors.isEmpty()) { logIngestModuleErrors(errors); } - dataSourceTasksProgress.finish(); } + + // Because there is only one data source task per job, it is o.k. to + // call ProgressHandle.finish() now that the data source ingest modules + // are through using it via the DataSourceIngestModuleProgress wrapper. + // Calling ProgressHandle.finish() again in finish() will be harmless. + dataSourceTasksProgress.finish(); + if (taskScheduler.isLastTaskForIngestJob(task)) { finish(); } } void process(FileIngestTask task) throws InterruptedException { - // If the job is not cancelled, complete the task, otherwise just flush - // it. if (!isCancelled()) { AbstractFile file = task.getFile(); synchronized (this) { @@ -230,10 +231,10 @@ final class IngestJob { if (!errors.isEmpty()) { logIngestModuleErrors(errors); } - + dataSourceTasksProgress.finish(); + fileTasksProgress.finish(); ingestJobsById.remove(id); - if (!cancelled) { - fileTasksProgress.finish(); + if (!isCancelled()) { IngestManager.getInstance().fireIngestJobCompleted(id); } } @@ -249,10 +250,7 @@ final class IngestJob { } private void cancel() { - taskScheduler.removeAllTasksForIngestJob(id); cancelled = true; - fileTasksProgress.finish(); - dataSourceTasksProgress.finish(); IngestManager.getInstance().fireIngestJobCancelled(id); } } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java index 330ddb6c6a..f202c3f2dc 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java @@ -121,33 +121,6 @@ final class IngestScheduler { addTaskToFileQueue(task); } } - - synchronized void removeAllTasksForIngestJob(long ingestJobId) { - Iterator fileTasksIterator = fileTasks.iterator(); - while (fileTasksIterator.hasNext()) { - if (fileTasksIterator.next().getIngestJob().getId() == ingestJobId) { - fileTasksIterator.remove(); - } - } - Iterator directoryTasksIterator = directoryTasks.iterator(); - while (directoryTasksIterator.hasNext()) { - if (directoryTasksIterator.next().getIngestJob().getId() == ingestJobId) { - directoryTasksIterator.remove(); - } - } - Iterator rootDirectoryTasksIterator = rootDirectoryTasks.iterator(); - while (rootDirectoryTasksIterator.hasNext()) { - if (rootDirectoryTasksIterator.next().getIngestJob().getId() == ingestJobId) { - rootDirectoryTasksIterator.remove(); - } - } - Iterator dataSourceTasksIterator = dataSourceTasks.iterator(); - while (dataSourceTasksIterator.hasNext()) { - if (dataSourceTasksIterator.next().getIngestJob().getId() == ingestJobId) { - dataSourceTasksIterator.remove(); - } - } - } private synchronized void updateFileTaskQueues(FileIngestTask taskInProgress) throws InterruptedException { if (taskInProgress != null) {