Skip to content
Snippets Groups Projects
Commit 789c4cca authored by apriestman's avatar apriestman
Browse files

Merge remote-tracking branch 'upstream/streaming-ingest' into 6430_moveDScreation

# Conflicts:
#	bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
parents 2041df9b 1c7c30a5
Branches
Tags
No related merge requests found
......@@ -50,7 +50,6 @@ public static void run(String imagePath) {
} catch (TskDataException ex) {
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
}
process.commit();
// print out all the images found, and their children
List<Image> images = sk.getImages();
......
......@@ -471,6 +471,7 @@ public class AddImageProcess {
private final boolean skipFatFsOrphans;
private final String imageWriterPath;
private volatile long tskAutoDbPointer;
private long imageId = 0;
private boolean isCanceled;
private final SleuthkitCase skCase;
private JniDbHelper dbHelper;
......@@ -501,8 +502,6 @@ private AddImageProcess(String timeZone, boolean addUnallocSpace, boolean skipFa
/**
* Starts the process of adding an image to the case database.
* Either AddImageProcess.commit or AddImageProcess.revert MUST be
* called after calling AddImageProcess.run.
*
* @param deviceId An ASCII-printable identifier for the
* device associated with the image that
......@@ -534,16 +533,19 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize) throws
* @param sectorSize The sector size (use '0' for autodetect).
* @param addDataSourceCallbacks The callbacks to use to send data to ingest (may do nothing).
*
* @return The object ID of the new image.
*
* @throws TskCoreException if a critical error occurs within the
* SleuthKit.
* @throws TskDataException if a non-critical error occurs within
* the SleuthKit (should be OK to continue
* the process)
*/
public void run(String deviceId, String[] imageFilePaths, int sectorSize,
public long run(String deviceId, String[] imageFilePaths, int sectorSize,
AddDataSourceCallbacks addDataSourceCallbacks) throws TskCoreException, TskDataException {
Image img = addImageToDatabase(skCase, imageFilePaths, sectorSize, "", "", "", "", deviceId);
run(deviceId, img, sectorSize, addDataSourceCallbacks);
run(deviceId, img, sectorSize, addDataSourceCallbacks);
return img.getId();
}
/**
......@@ -576,7 +578,6 @@ public void run(String deviceId, Image image, int sectorSize,
throw new TskCoreException("Add image process already started");
}
if (!isCanceled) { //with isCanceled being guarded by this it will have the same value everywhere in this synchronized block
//imageHandle = openImage(imageFilePaths, sectorSize, false, caseDbIdentifier);
imageHandle = image.getImageHandle();
tskAutoDbPointer = initAddImgNat(dbHelper, timezoneLongToShort(timeZone), addUnallocSpace, skipFatFsOrphans);
}
......@@ -588,6 +589,7 @@ public void run(String deviceId, Image image, int sectorSize,
runAddImgNat(tskAutoDbPointer, deviceId, imageHandle, image.getId(), timeZone, imageWriterPath);
}
} finally {
finishAddImageProcess();
releaseTSKReadLock();
}
}
......@@ -612,58 +614,62 @@ 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.
*
* @throws TskCoreException
*/
private synchronized void finishAddImageProcess() throws TskCoreException {
if (tskAutoDbPointer == 0) {
return;
}
// 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
imageId = finishAddImgNat(tskAutoDbPointer);
tskAutoDbPointer = 0;
skCase.addDataSourceToHasChildrenMap();
}
/**
* Rolls back the process of adding an image to the case database
* that was started by calling AddImageProcess.run.
* This no longer needs to be called.
*
* @throws TskCoreException if a critical error occurs within the
* SleuthKit.
*
* @deprecated No longer necessary
*/
@Deprecated
public synchronized void revert() throws TskCoreException {
getTSKReadLock();
try {
if (tskAutoDbPointer == 0) {
throw new TskCoreException("AddImgProcess::revert: AutoDB pointer is NULL");
}
// Delete the object in the native code
finishAddImgNat(tskAutoDbPointer);
tskAutoDbPointer = 0;
} finally {
releaseTSKReadLock();
}
// No-op
}
/**
* Completes the process of adding an image to the case database
* that was started by calling AddImageProcess.run.
* This no longer needs to be called. Will simply return the
* object ID of the new image.
*
* @return The object id of the image that was added.
*
* @throws TskCoreException if a critical error occurs within the
* SleuthKit.
*
* @deprecated No longer necessary
*/
@Deprecated
public synchronized long commit() throws TskCoreException {
getTSKReadLock();
try {
if (tskAutoDbPointer == 0) {
throw new TskCoreException("AddImgProcess::commit: AutoDB pointer is NULL");
}
if (dbHelper != null) {
dbHelper.finish();
}
// Get the image ID and delete the object in the native code
long id = finishAddImgNat(tskAutoDbPointer);
tskAutoDbPointer = 0;
skCase.addDataSourceToHasChildrenMap();
return id;
} finally {
releaseTSKReadLock();
}
return imageId;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment