diff --git a/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java b/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java index 01c2504980304f61e174835fccd4bee43816121e..cb6963fd3cf22bc0ce90b709f89172c517b87cf9 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java @@ -50,7 +50,7 @@ public static void run(String imagePath) { } catch (TskDataException ex) { Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex); } - process.commit(); + process.finishAddImageProcess(); // print out all the images found, and their children List<Image> images = sk.getImages(); diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java index ca10fccca3e7a63440edc703f4025d48d4053a76..5d72dde5f2fcab8165ecf83749952cf9d8660087 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java @@ -557,6 +557,7 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize, } if (imageHandle != 0) { runAddImgNat(tskAutoDbPointer, deviceId, imageHandle, timeZone, imageWriterPath); + dbHelper.finish(); } } finally { releaseTSKReadLock(); @@ -583,6 +584,42 @@ public synchronized void stop() throws TskCoreException { releaseTSKReadLock(); } } + + /** + * Call at the end of the add image process regardless of the error/canceled state. + * + * Note that the new image is no longer deleted on error/cancellation + * + * If the process was not canceled, will add the final batch of files to the database + * and submit for any further processing through the callback. + * + * @return The object ID of the newly added image + * + * @throws TskCoreException + */ + public synchronized long finishAddImageProcess() throws TskCoreException { + getTSKReadLock(); + try { + if (tskAutoDbPointer == 0) { + throw new TskCoreException("AddImgProcess::finishAddImageProcess: AutoDB pointer is NULL"); + } + + // If the process wasn't cancelled, finish up processing the + // remaining files. + if (! this.isCanceled && dbHelper != null) { + dbHelper.finish(); + } + + // Free the auto DB pointer and get the image ID + long id = finishAddImgNat(tskAutoDbPointer); + tskAutoDbPointer = 0; + + skCase.addDataSourceToHasChildrenMap(); + return id; + } finally { + releaseTSKReadLock(); + } + } /** * Rolls back the process of adding an image to the case database @@ -590,7 +627,9 @@ public synchronized void stop() throws TskCoreException { * * @throws TskCoreException if a critical error occurs within the * SleuthKit. + * @deprecated Use finishAddImageProcess() instead */ + @Deprecated public synchronized void revert() throws TskCoreException { getTSKReadLock(); try { @@ -614,7 +653,9 @@ public synchronized void revert() throws TskCoreException { * * @throws TskCoreException if a critical error occurs within the * SleuthKit. + * @deprecated Use finishAddImageProcess() instead */ + @Deprecated public synchronized long commit() throws TskCoreException { getTSKReadLock(); try {