mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-06 02:24:30 +00:00
Change ingest cancel
This commit is contained in:
@@ -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<IngestModuleError> 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<IngestModuleError> start() throws InterruptedException {
|
||||
private List<IngestModuleError> start() throws InterruptedException {
|
||||
List<IngestModuleError> 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<IngestModuleError> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,33 +121,6 @@ final class IngestScheduler {
|
||||
addTaskToFileQueue(task);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized void removeAllTasksForIngestJob(long ingestJobId) {
|
||||
Iterator<FileIngestTask> fileTasksIterator = fileTasks.iterator();
|
||||
while (fileTasksIterator.hasNext()) {
|
||||
if (fileTasksIterator.next().getIngestJob().getId() == ingestJobId) {
|
||||
fileTasksIterator.remove();
|
||||
}
|
||||
}
|
||||
Iterator<FileIngestTask> directoryTasksIterator = directoryTasks.iterator();
|
||||
while (directoryTasksIterator.hasNext()) {
|
||||
if (directoryTasksIterator.next().getIngestJob().getId() == ingestJobId) {
|
||||
directoryTasksIterator.remove();
|
||||
}
|
||||
}
|
||||
Iterator<FileIngestTask> rootDirectoryTasksIterator = rootDirectoryTasks.iterator();
|
||||
while (rootDirectoryTasksIterator.hasNext()) {
|
||||
if (rootDirectoryTasksIterator.next().getIngestJob().getId() == ingestJobId) {
|
||||
rootDirectoryTasksIterator.remove();
|
||||
}
|
||||
}
|
||||
Iterator<DataSourceIngestTask> 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) {
|
||||
|
||||
Reference in New Issue
Block a user