From e43bb45e774774a0c2537ad08424bc8d320eb95c Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 19 Mar 2021 15:19:52 -0400 Subject: [PATCH] Ingest progress snapshot fix for file ingest modules --- .../autopsy/ingest/FileIngestPipeline.java | 8 ++++- .../autopsy/ingest/IngestManager.java | 36 +++++++++++++------ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java b/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java index 3ba603a968..3904ddd529 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/FileIngestPipeline.java @@ -61,10 +61,17 @@ final class FileIngestPipeline extends IngestTaskPipeline { @Override void completeTask(FileIngestTask task) throws IngestTaskPipelineException { + ingestManager.setIngestTaskProgress(task, "Saving Files"); //NON-NLS AbstractFile file = null; try { file = task.getFile(); } catch (TskCoreException ex) { + /* + * In practice, the file should have already been lazily looked up + * and cached in the file task when the task was enqueued by the + * ingest tasks scheduler. Therefore there is no case database query + * here and there should be no TskCoreException. + */ throw new IngestTaskPipelineException(String.format("Failed to get file (file objId = %d)", task.getFileId()), ex); //NON-NLS } try { @@ -118,7 +125,6 @@ final class FileIngestPipeline extends IngestTaskPipeline { ingestManager.setIngestTaskProgress(task, getDisplayName()); ingestJobPipeline.setCurrentFileIngestModule(getDisplayName(), file.getName()); ProcessResult result = module.process(file); - ingestManager.setIngestTaskProgress(task, getDisplayName()); if (result == ProcessResult.ERROR) { throw new IngestModuleException(String.format("%s experienced an error analyzing %s (file objId = %d)", getDisplayName(), file.getName(), file.getId())); //NON-NLS } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index 7756b548c0..2f00900f20 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -769,24 +769,33 @@ public class IngestManager implements IngestProgressSnapshotProvider { } /** - * Updates the ingest progress snapshot for an ingest job when a data source - * level ingest module starts processing a data source from a data source - * ingest task. + * Updates the ingest progress snapshot for data source ingest task. This + * method should be called every time a new ingest module starts working on + * the task. * * @param task The data source ingest task. - * @param currentModuleName The display name of the current data source - * level ingest module. + * @param currentModuleName The display name of the currently processing + * module. */ void setIngestTaskProgress(DataSourceIngestTask task, String currentModuleName) { - ingestThreadActivitySnapshots.put(task.getThreadId(), new IngestThreadActivitySnapshot(task.getThreadId(), task.getIngestJobPipeline().getId(), currentModuleName, task.getDataSource())); + IngestThreadActivitySnapshot prevSnap = ingestThreadActivitySnapshots.get(task.getThreadId()); + IngestThreadActivitySnapshot newSnap = new IngestThreadActivitySnapshot(task.getThreadId(), task.getIngestJobPipeline().getId(), currentModuleName, task.getDataSource()); + ingestThreadActivitySnapshots.put(task.getThreadId(), newSnap); + + /* + * Update the total run time for the PREVIOUS ingest module, which has + * now finished its processing for the task. + */ + incrementModuleRunTime(prevSnap.getActivity(), newSnap.getStartTime().getTime() - prevSnap.getStartTime().getTime()); } /** - * Updates the ingest progress snapshot for an ingest job when a file ingest - * module starts or finishes processing a file from a file ingest task. + * Updates the ingest progress snapshot for data source ingest task. This + * method should be called every time a new ingest module starts working on + * the task. * * @param task The file ingest task. - * @param currentModuleName The display name of the current file ingest + * @param currentModuleName The display name of the currently processing * module. */ void setIngestTaskProgress(FileIngestTask task, String currentModuleName) { @@ -805,6 +814,11 @@ public class IngestManager implements IngestProgressSnapshotProvider { newSnap = new IngestThreadActivitySnapshot(task.getThreadId(), task.getIngestJobPipeline().getId(), currentModuleName, task.getDataSource()); } ingestThreadActivitySnapshots.put(task.getThreadId(), newSnap); + + /* + * Update the total run time for the PREVIOUS ingest module, which has + * now finished its processing for the task. + */ incrementModuleRunTime(prevSnap.getActivity(), newSnap.getStartTime().getTime() - prevSnap.getStartTime().getTime()); } @@ -812,7 +826,7 @@ public class IngestManager implements IngestProgressSnapshotProvider { * Updates the ingest progress snapshot for an ingest job when a data source * level ingest task is completed. * - * @param task The data source level ingest job task that was completed. + * @param task The ingest task. */ void setIngestTaskProgressCompleted(DataSourceIngestTask task) { ingestThreadActivitySnapshots.put(task.getThreadId(), new IngestThreadActivitySnapshot(task.getThreadId())); @@ -822,7 +836,7 @@ public class IngestManager implements IngestProgressSnapshotProvider { * Updates the ingest progress snapshot for an ingest job when a file ingest * task is completed. * - * @param task The file ingest task. + * @param task The ingest task. */ void setIngestTaskProgressCompleted(FileIngestTask task) { ingestThreadActivitySnapshots.put(task.getThreadId(), new IngestThreadActivitySnapshot(task.getThreadId()));