mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
Only do final search if this is the last module in this job to call endJob()
This commit is contained in:
parent
d3321853e0
commit
7913ecf25d
@ -80,7 +80,7 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
|||||||
//only search images from current ingest, not images previously ingested/indexed
|
//only search images from current ingest, not images previously ingested/indexed
|
||||||
//accessed read-only by searcher thread
|
//accessed read-only by searcher thread
|
||||||
private AtomicInteger messageID = new AtomicInteger(0);
|
private AtomicInteger messageID = new AtomicInteger(0);
|
||||||
private boolean processedFiles;
|
private boolean startedSearching = false;
|
||||||
private SleuthkitCase caseHandle = null;
|
private SleuthkitCase caseHandle = null;
|
||||||
private static List<AbstractFileExtract> textExtractors;
|
private static List<AbstractFileExtract> textExtractors;
|
||||||
private static AbstractFileStringExtract stringExtractor;
|
private static AbstractFileStringExtract stringExtractor;
|
||||||
@ -88,7 +88,7 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
|||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
private Tika tikaFormatDetector;
|
private Tika tikaFormatDetector;
|
||||||
private long jobId;
|
private long jobId;
|
||||||
private long dataSourceId;
|
private long dataSourceId;
|
||||||
|
|
||||||
private enum IngestStatus {
|
private enum IngestStatus {
|
||||||
|
|
||||||
@ -179,8 +179,6 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
|||||||
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.onlyIdxKwSkipMsg")));
|
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.onlyIdxKwSkipMsg")));
|
||||||
}
|
}
|
||||||
|
|
||||||
processedFiles = false;
|
|
||||||
|
|
||||||
indexer = new Indexer();
|
indexer = new Indexer();
|
||||||
|
|
||||||
final int updateIntervalMs = KeywordSearchSettings.getUpdateFrequency().getTime() * 60 * 1000;
|
final int updateIntervalMs = KeywordSearchSettings.getUpdateFrequency().getTime() * 60 * 1000;
|
||||||
@ -219,14 +217,15 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
|||||||
return ProcessResult.OK;
|
return ProcessResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
processedFiles = true;
|
|
||||||
|
|
||||||
//index the file and content (if the content is supported)
|
//index the file and content (if the content is supported)
|
||||||
indexer.indexFile(abstractFile, true);
|
indexer.indexFile(abstractFile, true);
|
||||||
|
|
||||||
// Start searching if it hasn't started already
|
// Start searching if it hasn't started already
|
||||||
List<String> keywordListNames = settings.getNamesOfEnabledKeyWordLists();
|
if (!startedSearching) {
|
||||||
SearchRunner.getInstance().startJob(jobId, dataSourceId, keywordListNames);
|
List<String> keywordListNames = settings.getNamesOfEnabledKeyWordLists();
|
||||||
|
SearchRunner.getInstance().startJob(jobId, dataSourceId, keywordListNames);
|
||||||
|
startedSearching = true;
|
||||||
|
}
|
||||||
|
|
||||||
return ProcessResult.OK;
|
return ProcessResult.OK;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import java.util.Map.Entry;
|
|||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
@ -97,6 +98,8 @@ public final class SearchRunner {
|
|||||||
jobs.put(jobId, jobData);
|
jobs.put(jobId, jobData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jobs.get(jobId).incrementModuleReferenceCount();
|
||||||
|
|
||||||
if (jobs.size() > 0) {
|
if (jobs.size() > 0) {
|
||||||
if (!updateTimer.isRunning()) {
|
if (!updateTimer.isRunning()) {
|
||||||
updateTimer.start();
|
updateTimer.start();
|
||||||
@ -111,16 +114,24 @@ public final class SearchRunner {
|
|||||||
*/
|
*/
|
||||||
public void endJob(long jobId) {
|
public void endJob(long jobId) {
|
||||||
SearchJobInfo job;
|
SearchJobInfo job;
|
||||||
|
boolean readyForFinalSearch = false;
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
job = jobs.get(jobId);
|
job = jobs.get(jobId);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jobs.remove(jobId);
|
|
||||||
|
// Only do final search if this is the last module in this job to call endJob()
|
||||||
|
if(job.decrementModuleReferenceCount() == 0) {
|
||||||
|
jobs.remove(jobId);
|
||||||
|
readyForFinalSearch = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readyForFinalSearch) {
|
||||||
|
commit();
|
||||||
|
doFinalSearch(job); //this will block until it's done
|
||||||
}
|
}
|
||||||
|
|
||||||
commit();
|
|
||||||
doFinalSearch(job); //this will block until it's done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -257,7 +268,8 @@ public final class SearchRunner {
|
|||||||
private List<String> keywordListNames; //guarded by SearchJobInfo.this
|
private List<String> keywordListNames; //guarded by SearchJobInfo.this
|
||||||
private Map<Keyword, List<Long>> currentResults; //guarded by SearchJobInfo.this
|
private Map<Keyword, List<Long>> currentResults; //guarded by SearchJobInfo.this
|
||||||
private SearchRunner.Searcher currentSearcher;
|
private SearchRunner.Searcher currentSearcher;
|
||||||
|
private AtomicLong moduleReferenceCount = new AtomicLong(0);
|
||||||
|
|
||||||
public SearchJobInfo(long jobId, long dataSourceId, List<String> keywordListNames) {
|
public SearchJobInfo(long jobId, long dataSourceId, List<String> keywordListNames) {
|
||||||
this.jobId = jobId;
|
this.jobId = jobId;
|
||||||
this.dataSourceId = dataSourceId;
|
this.dataSourceId = dataSourceId;
|
||||||
@ -306,6 +318,14 @@ public final class SearchRunner {
|
|||||||
public synchronized void setCurrentSearcher(SearchRunner.Searcher searchRunner) {
|
public synchronized void setCurrentSearcher(SearchRunner.Searcher searchRunner) {
|
||||||
currentSearcher = searchRunner;
|
currentSearcher = searchRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void incrementModuleReferenceCount() {
|
||||||
|
moduleReferenceCount.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long decrementModuleReferenceCount() {
|
||||||
|
return moduleReferenceCount.decrementAndGet();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user