From b0e488c6926c0ae1f1863f1b7a0a67c84f18574f Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Tue, 28 Jul 2015 10:09:21 -0400 Subject: [PATCH] Add early out for cancelled jobs to process() for ingest module pipelines --- .../ingest/DataSourceIngestPipeline.java | 57 ++++++++++--------- .../autopsy/ingest/FileIngestPipeline.java | 48 +++++++++------- 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java index 7bd84436d6..71a48df7d7 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestPipeline.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2014 Basis Technology Corp. + * Copyright 2014-2015 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,7 +37,7 @@ import org.sleuthkit.datamodel.Content; final class DataSourceIngestPipeline { private static final IngestManager ingestManager = IngestManager.getInstance(); - private static final Logger logger = Logger.getLogger(DataSourceIngestPipeline.class.getName()); + private static final Logger logger = Logger.getLogger(DataSourceIngestPipeline.class.getName()); private final DataSourceIngestJob job; private final List modules = new ArrayList<>(); private volatile PipelineModule currentModule; @@ -96,31 +96,34 @@ final class DataSourceIngestPipeline { */ synchronized List process(DataSourceIngestTask task) { List errors = new ArrayList<>(); - Content dataSource = task.getDataSource(); - for (PipelineModule module : modules) { - try { - this.currentModule = module; - String displayName = NbBundle.getMessage(this.getClass(), - "IngestJob.progress.dataSourceIngest.displayName", - module.getDisplayName(), dataSource.getName()); - this.job.updateDataSourceIngestProgressBarDisplayName(displayName); - this.job.switchDataSourceIngestProgressBarToIndeterminate(); - DataSourceIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName()); - logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) starting", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()}); - module.process(dataSource, new DataSourceIngestModuleProgress(this.job)); - logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) finished", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()}); - } catch (Throwable ex) { // Catch-all exception firewall - errors.add(new IngestModuleError(module.getDisplayName(), ex)); - String msg = ex.getMessage(); - // Jython run-time errors don't seem to have a message, but have details in toString. - if (msg == null) - msg = ex.toString(); - MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg); - } - if (this.job.isCancelled()) { - break; - } else if (this.job.currentDataSourceIngestModuleIsCancelled()) { - this.job.currentDataSourceIngestModuleCancellationCompleted(currentModule.getDisplayName()); + if (!this.job.isCancelled()) { + Content dataSource = task.getDataSource(); + for (PipelineModule module : modules) { + try { + this.currentModule = module; + String displayName = NbBundle.getMessage(this.getClass(), + "IngestJob.progress.dataSourceIngest.displayName", + module.getDisplayName(), dataSource.getName()); + this.job.updateDataSourceIngestProgressBarDisplayName(displayName); + this.job.switchDataSourceIngestProgressBarToIndeterminate(); + DataSourceIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName()); + logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) starting", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()}); + module.process(dataSource, new DataSourceIngestModuleProgress(this.job)); + logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) finished", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()}); + } catch (Throwable ex) { // Catch-all exception firewall + errors.add(new IngestModuleError(module.getDisplayName(), ex)); + String msg = ex.getMessage(); + // Jython run-time errors don't seem to have a message, but have details in toString. + if (msg == null) { + msg = ex.toString(); + } + MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg); + } + if (this.job.isCancelled()) { + break; + } else if (this.job.currentDataSourceIngestModuleIsCancelled()) { + this.job.currentDataSourceIngestModuleCancellationCompleted(currentModule.getDisplayName()); + } } } this.currentModule = null; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java b/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java index 1bacdc566f..22715fef58 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2014 Basis Technology Corp. + * Copyright 2014-2015 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -113,26 +113,29 @@ final class FileIngestPipeline { */ synchronized List process(FileIngestTask task) { List errors = new ArrayList<>(); - AbstractFile file = task.getFile(); - for (PipelineModule module : this.modules) { - try { - FileIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName()); - module.process(file); - } catch (Throwable ex) { // Catch-all exception firewall - errors.add(new IngestModuleError(module.getDisplayName(), ex)); - String msg = ex.getMessage(); - // Jython run-time errors don't seem to have a message, but have details in toString. - if (msg == null) - msg = ex.toString(); - MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg); - } - if (this.job.isCancelled()) { - break; - } - } - file.close(); if (!this.job.isCancelled()) { - IngestManager.getInstance().fireFileIngestDone(file); + AbstractFile file = task.getFile(); + for (PipelineModule module : this.modules) { + try { + FileIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName()); + module.process(file); + } catch (Throwable ex) { // Catch-all exception firewall + errors.add(new IngestModuleError(module.getDisplayName(), ex)); + String msg = ex.getMessage(); + // Jython run-time errors don't seem to have a message, but have details in toString. + if (msg == null) { + msg = ex.toString(); + } + MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg); + } + if (this.job.isCancelled()) { + break; + } + } + file.close(); + if (!this.job.isCancelled()) { + IngestManager.getInstance().fireFileIngestDone(file); + } } FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task); return errors; @@ -145,7 +148,7 @@ final class FileIngestPipeline { */ synchronized List shutDown() { List errors = new ArrayList<>(); - if(this.running == true){ // Don't shut down pipelines that never started + if (this.running == true) { // Don't shut down pipelines that never started for (PipelineModule module : this.modules) { try { module.shutDown(); @@ -153,8 +156,9 @@ final class FileIngestPipeline { errors.add(new IngestModuleError(module.getDisplayName(), ex)); String msg = ex.getMessage(); // Jython run-time errors don't seem to have a message, but have details in toString. - if (msg == null) + if (msg == null) { msg = ex.toString(); + } MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg); } }