Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sleuthkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRT
Sleuthkit
Commits
1c7c30a5
Unverified
Commit
1c7c30a5
authored
4 years ago
by
Richard Cordovano
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1959 from APriestman/6378_dspErrorHandling
6378 Change success/error handling for addImageProcess
parents
752fb305
2189255b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java
+0
-1
0 additions, 1 deletion
...ngs/java/src/org/sleuthkit/datamodel/Examples/Sample.java
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
+48
-38
48 additions, 38 deletions
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
with
48 additions
and
39 deletions
bindings/java/src/org/sleuthkit/datamodel/Examples/Sample.java
+
0
−
1
View file @
1c7c30a5
...
@@ -50,7 +50,6 @@ public static void run(String imagePath) {
...
@@ -50,7 +50,6 @@ public static void run(String imagePath) {
}
catch
(
TskDataException
ex
)
{
}
catch
(
TskDataException
ex
)
{
Logger
.
getLogger
(
Sample
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
Sample
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
process
.
commit
();
// print out all the images found, and their children
// print out all the images found, and their children
List
<
Image
>
images
=
sk
.
getImages
();
List
<
Image
>
images
=
sk
.
getImages
();
...
...
This diff is collapsed.
Click to expand it.
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
+
48
−
38
View file @
1c7c30a5
...
@@ -468,6 +468,7 @@ public class AddImageProcess {
...
@@ -468,6 +468,7 @@ public class AddImageProcess {
private
final
boolean
skipFatFsOrphans
;
private
final
boolean
skipFatFsOrphans
;
private
final
String
imageWriterPath
;
private
final
String
imageWriterPath
;
private
volatile
long
tskAutoDbPointer
;
private
volatile
long
tskAutoDbPointer
;
private
long
imageId
=
0
;
private
boolean
isCanceled
;
private
boolean
isCanceled
;
private
final
SleuthkitCase
skCase
;
private
final
SleuthkitCase
skCase
;
private
JniDbHelper
dbHelper
;
private
JniDbHelper
dbHelper
;
...
@@ -498,8 +499,6 @@ private AddImageProcess(String timeZone, boolean addUnallocSpace, boolean skipFa
...
@@ -498,8 +499,6 @@ private AddImageProcess(String timeZone, boolean addUnallocSpace, boolean skipFa
/**
/**
* Starts the process of adding an image to the case database.
* 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
* @param deviceId An ASCII-printable identifier for the
* device associated with the image that
* device associated with the image that
...
@@ -531,13 +530,15 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize) throws
...
@@ -531,13 +530,15 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize) throws
* @param sectorSize The sector size (use '0' for autodetect).
* @param sectorSize The sector size (use '0' for autodetect).
* @param addDataSourceCallbacks The callbacks to use to send data to ingest (may do nothing).
* @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
* @throws TskCoreException if a critical error occurs within the
* SleuthKit.
* SleuthKit.
* @throws TskDataException if a non-critical error occurs within
* @throws TskDataException if a non-critical error occurs within
* the SleuthKit (should be OK to continue
* the SleuthKit (should be OK to continue
* the process)
* 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
{
AddDataSourceCallbacks
addDataSourceCallbacks
)
throws
TskCoreException
,
TskDataException
{
dbHelper
=
new
JniDbHelper
(
skCase
,
addDataSourceCallbacks
);
dbHelper
=
new
JniDbHelper
(
skCase
,
addDataSourceCallbacks
);
getTSKReadLock
();
getTSKReadLock
();
...
@@ -557,10 +558,15 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize,
...
@@ -557,10 +558,15 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize,
}
}
if
(
imageHandle
!=
0
)
{
if
(
imageHandle
!=
0
)
{
runAddImgNat
(
tskAutoDbPointer
,
deviceId
,
imageHandle
,
timeZone
,
imageWriterPath
);
runAddImgNat
(
tskAutoDbPointer
,
deviceId
,
imageHandle
,
timeZone
,
imageWriterPath
);
}
}
}
finally
{
}
finally
{
finishAddImageProcess
();
releaseTSKReadLock
();
releaseTSKReadLock
();
}
}
synchronized
(
this
)
{
return
imageId
;
}
}
}
/**
/**
...
@@ -583,58 +589,62 @@ public synchronized void stop() throws TskCoreException {
...
@@ -583,58 +589,62 @@ public synchronized void stop() throws TskCoreException {
releaseTSKReadLock
();
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
* This no longer needs to be called.
* that was started by calling AddImageProcess.run.
*
*
* @throws TskCoreException if a critical error occurs within the
* @throws TskCoreException if a critical error occurs within the
* SleuthKit.
* SleuthKit.
*
* @deprecated No longer necessary
*/
*/
@Deprecated
public
synchronized
void
revert
()
throws
TskCoreException
{
public
synchronized
void
revert
()
throws
TskCoreException
{
getTSKReadLock
();
// No-op
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
();
}
}
}
/**
/**
*
Completes the process of adding an image to the case database
*
This no longer needs to be called. Will simply return the
*
that was started by calling AddImageProcess.run
.
*
object ID of the new image
.
*
*
* @return The object id of the image that was added.
* @return The object id of the image that was added.
*
*
* @throws TskCoreException if a critical error occurs within the
* @throws TskCoreException if a critical error occurs within the
* SleuthKit.
* SleuthKit.
*
* @deprecated No longer necessary
*/
*/
@Deprecated
public
synchronized
long
commit
()
throws
TskCoreException
{
public
synchronized
long
commit
()
throws
TskCoreException
{
getTSKReadLock
();
return
imageId
;
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
();
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment