From 8d391fd07762e3d885ba2a21cc897c7c0c35e7d9 Mon Sep 17 00:00:00 2001 From: jmillman Date: Mon, 14 Sep 2015 16:36:34 -0400 Subject: [PATCH 1/2] fix SQL query when there are no FileSystems in an Image --- ImageGallery/nbproject/suite.properties | 1 + .../imagegallery/ImageGalleryController.java | 37 ++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 ImageGallery/nbproject/suite.properties diff --git a/ImageGallery/nbproject/suite.properties b/ImageGallery/nbproject/suite.properties new file mode 100644 index 0000000000..29d7cc9bd6 --- /dev/null +++ b/ImageGallery/nbproject/suite.properties @@ -0,0 +1 @@ +suite.dir=${basedir}/.. diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java index fddef3379c..5c34d9e89e 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java @@ -19,13 +19,13 @@ package org.sleuthkit.autopsy.imagegallery; import java.beans.PropertyChangeEvent; -import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.logging.Level; +import java.util.stream.Collectors; import javafx.application.Platform; import javafx.beans.Observable; import javafx.beans.property.ReadOnlyBooleanProperty; @@ -875,7 +875,7 @@ public final class ImageGalleryController { * check for supported images */ // (name like '.jpg' or name like '.png' ...) - private final String DRAWABLE_QUERY = "(name LIKE '%." + StringUtils.join(FileTypeUtils.getAllSupportedExtensions(), "' or name LIKE '%.") + "') "; + private final String DRAWABLE_QUERY = "(name LIKE '%." + StringUtils.join(FileTypeUtils.getAllSupportedExtensions(), "' OR name LIKE '%.") + "') "; private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("prepopulating image/video database"); @@ -889,29 +889,32 @@ public final class ImageGalleryController { } /** - * Copy files from a newly added data source into the DB + * Copy files from a newly added data source into the DB. Get all + * "drawable" files, based on extension. After ingest we use file type + * id module and if necessary jpeg signature matching to add/remove + * files */ @Override public void run() { progressHandle.start(); updateMessage("prepopulating image/video database"); - /* - * Get all "drawable" files, based on extension. After ingest we use - * file type id module and if necessary jpeg signature matching to - * add/remove files - */ - final List files; try { - List fsObjIds = new ArrayList<>(); - - String fsQuery; + String fsQuery = ""; if (dataSource instanceof Image) { - Image image = (Image) dataSource; - for (FileSystem fs : image.getFileSystems()) { - fsObjIds.add(fs.getId()); + List fileSystems = ((Image) dataSource).getFileSystems(); + if (fileSystems.isEmpty() == false) { + /* + * no filesystems, don't bother with the initial + * population, just catch things on file_done + */ + progressHandle.finish(); + return; } - fsQuery = "(fs_obj_id = " + StringUtils.join(fsObjIds, " or fs_obj_id = ") + ") "; + String internal = fileSystems.stream() + .map(fileSystem -> String.valueOf(fileSystem.getId())) + .collect(Collectors.joining(" OR fs_obj_id = ")); + fsQuery = "(fs_obj_id = " + internal + ") "; //suffix } else { /* * NOTE: Logical files currently (Apr '15) have a null value @@ -923,7 +926,7 @@ public final class ImageGalleryController { fsQuery = "(fs_obj_id IS NULL) "; } - files = getSleuthKitCase().findAllFilesWhere(fsQuery + " and " + DRAWABLE_QUERY); + final List files = getSleuthKitCase().findAllFilesWhere(fsQuery + " AND " + DRAWABLE_QUERY); progressHandle.switchToDeterminate(files.size()); //do in transaction From e35fa1ed90cec520355e80bcafea3de95291230b Mon Sep 17 00:00:00 2001 From: momo Date: Wed, 16 Sep 2015 13:53:36 -0400 Subject: [PATCH 2/2] uncomment path initialization code --- .../modules/embeddedfileextractor/SevenZipExtractor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java index ffcdc5b34b..9aacb0619f 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java @@ -251,7 +251,7 @@ class SevenZipExtractor { } if (detectedFormat == null) { - logger.log(Level.WARNING, "Could not detect format for file: " + archiveFile); //NON-NLS + logger.log(Level.WARNING, "Could not detect format for file: {0}", archiveFile); //NON-NLS // if we don't have attribute info then use file extension String extension = archiveFile.getNameExtension(); @@ -901,7 +901,7 @@ class SevenZipExtractor { UnpackedNode(String fileName, UnpackedNode parent) { this.fileName = fileName; this.parent = parent; - //this.localRelPath = parent.localRelPath + File.separator + fileName; + this.localRelPath = parent.localRelPath + File.separator + fileName; //new child derived file will be set by unpack() method parent.children.add(this);