mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Merge pull request #1767 from millmanorama/IG-hashsetmanager-performance
reduce db roundtrips in HashSetManager.getHashSetsForFileHelper
This commit is contained in:
commit
26c7e2d597
@ -54,6 +54,8 @@ import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager;
|
||||
import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupSortBy;
|
||||
import static org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupSortBy.GROUP_BY_VALUE;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
@ -475,6 +477,32 @@ public final class DrawableDB {
|
||||
return con.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the names of the hashsets that the given fileID belongs to
|
||||
*
|
||||
* @param fileID the fileID to get all the Hashset names for
|
||||
*
|
||||
* @return a set of hash set names, each of which the given file belongs to
|
||||
*
|
||||
* @throws TskCoreException
|
||||
*
|
||||
*
|
||||
* //TODO: this is mostly a cut and paste from *
|
||||
* AbstractContent.getHashSetNames, is there away to dedupe?
|
||||
*/
|
||||
Set<String> getHashSetsForFile(long fileID) throws TskCoreException {
|
||||
Set<String> hashNames = new HashSet<>();
|
||||
ArrayList<BlackboardArtifact> artifacts = tskCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT, fileID);
|
||||
|
||||
for (BlackboardArtifact a : artifacts) {
|
||||
List<BlackboardAttribute> attributes = a.getAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME);
|
||||
for (BlackboardAttribute attr : attributes) {
|
||||
hashNames.add(attr.getValueString());
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableSet(hashNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all the hash set names used in the db
|
||||
*
|
||||
|
@ -44,7 +44,7 @@ public class HashSetManager {
|
||||
*/
|
||||
private Set<String> getHashSetsForFileHelper(long fileID) {
|
||||
try {
|
||||
return db.getFileFromID(fileID).getHashSetNames();
|
||||
return db.getHashSetsForFile(fileID);
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(HashSetManager.class.getName()).log(Level.SEVERE, "Failed to get Hash Sets for file", ex);
|
||||
return Collections.emptySet();
|
||||
|
Loading…
x
Reference in New Issue
Block a user