mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
minor cleanup
This commit is contained in:
parent
cebd1f62b9
commit
5502beac60
@ -120,7 +120,7 @@ public class AutopsyListener {
|
||||
}
|
||||
} else {
|
||||
controller.setStale(true);
|
||||
//TODO: keep track of waht we missed for later
|
||||
//TODO: keep track of what we missed for later
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -22,8 +22,10 @@ import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -39,6 +41,7 @@ import javax.imageio.IIOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.Utilities;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.corelibs.ScalrWrapper;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -46,8 +49,10 @@ import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile;
|
||||
import org.sleuthkit.datamodel.ReadContentInputStream;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/** Manages creation and access of icons. Keeps a cache in memory of most
|
||||
* recently used icons, and a disk cache of all icons. */
|
||||
/**
|
||||
* Singleton to manage creation and access of icons. Keeps a cache in memory of
|
||||
* most * recently used icons, and a disk cache of all icons.
|
||||
*/
|
||||
public class IconCache {
|
||||
|
||||
static private IconCache instance;
|
||||
@ -63,7 +68,6 @@ public class IconCache {
|
||||
private final Executor imageSaver = Executors.newSingleThreadExecutor(new BasicThreadFactory.Builder().namingPattern("icon saver-%d").build());
|
||||
|
||||
private IconCache() {
|
||||
|
||||
}
|
||||
|
||||
synchronized static public IconCache getDefault() {
|
||||
@ -106,14 +110,13 @@ public class IconCache {
|
||||
if (cacheFile.exists()) {
|
||||
try {
|
||||
int dim = iconSize.get();
|
||||
icon = new Image(cacheFile.toURI().toURL().toString(), dim, dim, true, false, true);
|
||||
icon = new Image(Utilities.toURI(cacheFile).toURL().toString(), dim, dim, true, false, true);
|
||||
} catch (MalformedURLException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (icon == null) {
|
||||
// Logger.getAnonymousLogger().warning("wrong size cache found for image " + getName());
|
||||
icon = generateAndSaveIcon(file);
|
||||
}
|
||||
return Optional.ofNullable(icon);
|
||||
@ -126,11 +129,10 @@ public class IconCache {
|
||||
|
||||
private Image generateAndSaveIcon(final DrawableFile<?> file) {
|
||||
Image img;
|
||||
//TODO: should we wrap this in a BufferedInputStream? -jm
|
||||
try (ReadContentInputStream inputStream = new ReadContentInputStream(file.getAbstractFile())) {
|
||||
try (InputStream inputStream = new BufferedInputStream(new ReadContentInputStream(file.getAbstractFile()))) {
|
||||
img = new Image(inputStream, MAX_ICON_SIZE, MAX_ICON_SIZE, true, true);
|
||||
if (img.isError()) {
|
||||
LOGGER.log(Level.WARNING, "problem loading image: {0}. {1}", new Object[]{file.getName(), img.getException().getLocalizedMessage()});
|
||||
LOGGER.log(Level.WARNING, "problem loading image: " + file.getName() + " .", img.getException());
|
||||
return fallbackToSwingImage(file);
|
||||
} else {
|
||||
imageSaver.execute(() -> {
|
||||
@ -189,15 +191,6 @@ public class IconCache {
|
||||
|
||||
private void saveIcon(final DrawableFile<?> file, final Image bi) {
|
||||
try {
|
||||
/* save the icon in a background thread. profiling
|
||||
* showed that it can take as much time as making
|
||||
* the icon? -bc
|
||||
*
|
||||
* We don't do this now as it doesn't fit the
|
||||
* current model of ui-related backgroiund tasks,
|
||||
* and there might be complications to not just
|
||||
* blocking (eg having more than one task to
|
||||
* create the same icon -jm */
|
||||
File f = getCacheFile(file.getId());
|
||||
ImageIO.write(SwingFXUtils.fromFXImage(bi, null), "png", f);
|
||||
} catch (IOException ex) {
|
||||
|
@ -55,7 +55,7 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
/**
|
||||
* @TODO: There is something I don't understand or have done wrong about
|
||||
* implementing this class,as it is unreadable by
|
||||
* {@link ReadContentInputStream}. As a work around I kept a reference to the
|
||||
* {@link ReadContentInputStream}. As a work around we keep a reference to the
|
||||
* original {@link AbstractFile} to use when reading the image. -jm
|
||||
*/
|
||||
public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile {
|
||||
@ -80,8 +80,6 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
|
||||
private String drawablePath;
|
||||
|
||||
abstract public boolean isVideo();
|
||||
|
||||
protected T file;
|
||||
|
||||
private final SimpleBooleanProperty analyzed;
|
||||
@ -90,11 +88,6 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
|
||||
private Collection<String> hashHitSetNames;
|
||||
|
||||
public Collection<String> getHashHitSetNames() {
|
||||
updateHashSets();
|
||||
return hashHitSetNames;
|
||||
}
|
||||
|
||||
private String make;
|
||||
|
||||
private String model;
|
||||
@ -102,7 +95,7 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
protected DrawableFile(T file, Boolean analyzed) {
|
||||
/* @TODO: the two 'new Integer(0).shortValue()' values and null are
|
||||
* placeholders because the super constructor expects values i can't get
|
||||
* easily at the moment */
|
||||
* easily at the moment. I assume this is related to why ReadContentInputStream can't read from DrawableFiles.*/
|
||||
|
||||
super(file.getSleuthkitCase(), file.getId(), file.getAttrType(), file.getAttrId(), file.getName(), file.getType(), file.getMetaAddr(), (int) file.getMetaSeq(), file.getDirType(), file.getMetaType(), null, new Integer(0).shortValue(), file.getSize(), file.getCtime(), file.getCrtime(), file.getAtime(), file.getMtime(), new Integer(0).shortValue(), file.getUid(), file.getGid(), file.getMd5Hash(), file.getKnown(), file.getParentPath());
|
||||
this.analyzed = new SimpleBooleanProperty(analyzed);
|
||||
@ -110,6 +103,13 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
|
||||
}
|
||||
|
||||
public abstract boolean isVideo();
|
||||
|
||||
public Collection<String> getHashHitSetNames() {
|
||||
updateHashSets();
|
||||
return hashHitSetNames;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void updateHashSets() {
|
||||
hashHitSetNames = (Collection<String>) getValuesOfBBAttribute(BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME);
|
||||
@ -178,7 +178,7 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
final protected List<? extends Object> getValuesOfBBAttribute(BlackboardArtifact.ARTIFACT_TYPE artType, BlackboardAttribute.ATTRIBUTE_TYPE attrType) {
|
||||
protected final List<? extends Object> getValuesOfBBAttribute(BlackboardArtifact.ARTIFACT_TYPE artType, BlackboardAttribute.ATTRIBUTE_TYPE attrType) {
|
||||
ArrayList<Object> vals = new ArrayList<>();
|
||||
try {
|
||||
//why doesn't file.getArtifacts() work?
|
||||
@ -309,7 +309,6 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
} else {
|
||||
try {
|
||||
drawablePath = StringUtils.removeEnd(getUniquePath(), getName());
|
||||
// drawablePath = StringUtils.replaceEachRepeatedly(drawablePath, DOUBLE_SLASH, SLASH);
|
||||
return drawablePath;
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(DrawableFile.class.getName()).log(Level.WARNING, "failed to get drawablePath from {0}", getName());
|
||||
@ -317,17 +316,4 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getRootID() throws TskCoreException {
|
||||
|
||||
Content myParent = getParent();
|
||||
long id = -1;
|
||||
|
||||
while (myParent != null) {
|
||||
id = myParent.getId();
|
||||
myParent = myParent.getParent();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user