mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #2963 from millmanorama/2853-boost-nodecount-threshold
raise the threshold to 1M files, some very minor cleanup
This commit is contained in:
commit
278ff0bf7e
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2016 Basis Technology Corp.
|
* Copyright 2011-2017 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -47,10 +47,24 @@ import org.sleuthkit.datamodel.TskCoreException;
|
|||||||
*/
|
*/
|
||||||
public final class FileTypes implements AutopsyVisitableItem {
|
public final class FileTypes implements AutopsyVisitableItem {
|
||||||
|
|
||||||
private final static Logger logger = Logger.getLogger(FileTypes.class.getName());
|
private static final Logger logger = Logger.getLogger(FileTypes.class.getName());
|
||||||
|
@NbBundle.Messages("FileTypes.name.text=File Types")
|
||||||
|
private static final String NAME = Bundle.FileTypes_name_text();
|
||||||
|
/**
|
||||||
|
* Threshold used to limit db queries for child node counts. When the
|
||||||
|
* tsk_files table has more than this number of rows, we don't query for the
|
||||||
|
* child node counts, and since we don't have an accurate number we don't
|
||||||
|
* show the counts.
|
||||||
|
*/
|
||||||
|
private static final int NODE_COUNT_FILE_TABLE_THRESHOLD = 1_000_000;
|
||||||
|
/**
|
||||||
|
* Used to keep track of whether we have hit
|
||||||
|
* NODE_COUNT_FILE_TABLE_THRESHOLD. If we have, we stop querying for the
|
||||||
|
* number of rows in tsk_files, since it is already too large.
|
||||||
|
*/
|
||||||
|
private boolean showCounts = true;
|
||||||
|
|
||||||
private final SleuthkitCase skCase;
|
private final SleuthkitCase skCase;
|
||||||
private boolean showCounts = true;
|
|
||||||
|
|
||||||
FileTypes(SleuthkitCase skCase) {
|
FileTypes(SleuthkitCase skCase) {
|
||||||
this.skCase = skCase;
|
this.skCase = skCase;
|
||||||
@ -66,15 +80,16 @@ public final class FileTypes implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the nodes show counts?
|
* Check the db to determine if the nodes should show child counts.
|
||||||
*
|
*/
|
||||||
*
|
void updateShowCounts() {
|
||||||
* @return True, unless the DB has more than 200k rows.
|
/*
|
||||||
|
* once we have passed the threshold, we don't need to keep checking the
|
||||||
|
* number of rows in tsk_files
|
||||||
*/
|
*/
|
||||||
boolean shouldShowCounts() {
|
|
||||||
if (showCounts) {
|
if (showCounts) {
|
||||||
try {
|
try {
|
||||||
if (skCase.countFilesWhere("1=1") > 200000) { //NON-NLS
|
if (skCase.countFilesWhere("1=1") > NODE_COUNT_FILE_TABLE_THRESHOLD) { //NON-NLS
|
||||||
showCounts = false;
|
showCounts = false;
|
||||||
}
|
}
|
||||||
} catch (TskCoreException tskCoreException) {
|
} catch (TskCoreException tskCoreException) {
|
||||||
@ -82,10 +97,7 @@ public final class FileTypes implements AutopsyVisitableItem {
|
|||||||
logger.log(Level.SEVERE, "Error counting files.", tskCoreException); //NON-NLS
|
logger.log(Level.SEVERE, "Error counting files.", tskCoreException); //NON-NLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return showCounts;
|
|
||||||
}
|
}
|
||||||
@NbBundle.Messages("FileTypes.name.text=File Types")
|
|
||||||
static private final String NAME = Bundle.FileTypes_name_text();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node which will contain By Mime Type and By Extension nodes.
|
* Node which will contain By Mime Type and By Extension nodes.
|
||||||
@ -97,8 +109,8 @@ public final class FileTypes implements AutopsyVisitableItem {
|
|||||||
new FileTypesByExtension(FileTypes.this),
|
new FileTypesByExtension(FileTypes.this),
|
||||||
new FileTypesByMimeType(FileTypes.this))),
|
new FileTypesByMimeType(FileTypes.this))),
|
||||||
Lookups.singleton(NAME));
|
Lookups.singleton(NAME));
|
||||||
setName(NAME);
|
this.setName(NAME);
|
||||||
setDisplayName(NAME);
|
this.setDisplayName(NAME);
|
||||||
this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file_types.png"); //NON-NLS
|
this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file_types.png"); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,9 +227,9 @@ public final class FileTypes implements AutopsyVisitableItem {
|
|||||||
* Updates the display name of the mediaSubTypeNode to include the count
|
* Updates the display name of the mediaSubTypeNode to include the count
|
||||||
* of files which it represents.
|
* of files which it represents.
|
||||||
*/
|
*/
|
||||||
@NbBundle.Messages("FileTypes.bgCounting.placeholder=(counting...)")
|
@NbBundle.Messages("FileTypes.bgCounting.placeholder= (counting...)")
|
||||||
void updateDisplayName() {
|
void updateDisplayName() {
|
||||||
if (typesRoot.shouldShowCounts()) {
|
if (typesRoot.showCounts) {
|
||||||
//only show "(counting...)" the first time, otherwise it is distracting.
|
//only show "(counting...)" the first time, otherwise it is distracting.
|
||||||
setDisplayName(getDisplayNameBase() + ((childCount < 0) ? Bundle.FileTypes_bgCounting_placeholder()
|
setDisplayName(getDisplayNameBase() + ((childCount < 0) ? Bundle.FileTypes_bgCounting_placeholder()
|
||||||
: ("(" + childCount + ")"))); //NON-NLS
|
: ("(" + childCount + ")"))); //NON-NLS
|
||||||
@ -239,7 +251,7 @@ public final class FileTypes implements AutopsyVisitableItem {
|
|||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
} else {
|
} else {
|
||||||
setDisplayName(getDisplayNameBase() + ((childCount < 0) ? "" : ("(" + childCount + "+)"))); //NON-NLS
|
setDisplayName(getDisplayNameBase() + ((childCount < 0) ? "" : (" (" + childCount + "+)"))); //NON-NLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem {
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
Case.getCurrentCase();
|
Case.getCurrentCase();
|
||||||
typesRoot.shouldShowCounts();
|
typesRoot.updateShowCounts();
|
||||||
update();
|
update();
|
||||||
} catch (IllegalStateException notUsed) {
|
} catch (IllegalStateException notUsed) {
|
||||||
/**
|
/**
|
||||||
|
@ -158,7 +158,7 @@ public final class FileTypesByMimeType extends Observable implements AutopsyVisi
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
Case.getCurrentCase();
|
Case.getCurrentCase();
|
||||||
typesRoot.shouldShowCounts();
|
typesRoot.updateShowCounts();
|
||||||
populateHashMap();
|
populateHashMap();
|
||||||
} catch (IllegalStateException notUsed) {
|
} catch (IllegalStateException notUsed) {
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user