Skip to content
Snippets Groups Projects
Commit ffcac9e8 authored by Brian Carrier's avatar Brian Carrier
Browse files

more error checking on DB commit / revert

parent 177b9d86
No related branches found
No related tags found
No related merge requests found
......@@ -370,7 +370,11 @@ JNIEXPORT void JNICALL
"revertAddImgNat: Invalid TskAutoDb object passed in");
return;
}
tskAuto->revertAddImage();
if (tskAuto->revertAddImage()) {
throwTskError(env,
"revertAddImgNat: Error reverting transaction");
return;
}
delete tskAuto;
}
......@@ -392,6 +396,11 @@ JNIEXPORT jlong JNICALL
}
int64_t imgId = tskAuto->commitAddImage();
delete tskAuto;
if (imgId == -1) {
throwTskError(env,
"commit addImgNat: Error commiting image");
return -1;
}
return imgId;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>DataModel</name>
</general-data>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
<!-- Do not use Project Properties customizer when editing this file manually. -->
<name>DataModel</name>
<properties/>
<folders>
<source-folder>
<label>DataModel</label>
<location>.</location>
<encoding>windows-1252</encoding>
</source-folder>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
<encoding>windows-1252</encoding>
</source-folder>
<source-folder>
<label>test</label>
<type>java</type>
<location>test</location>
<encoding>windows-1252</encoding>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>compile</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>compile</target>
</action>
<action name="run.single">
<script>nbproject/ide-file-targets.xml</script>
<target>run-selected-file-in-test</target>
<context>
<property>run.class</property>
<folder>test</folder>
<pattern>\.java$</pattern>
<format>java-name</format>
<arity>
<one-file-only/>
</arity>
</context>
</action>
<action name="compile.single">
<script>nbproject/ide-file-targets.xml</script>
<target>compile-selected-files-in-test</target>
<context>
<property>files</property>
<folder>test</folder>
<pattern>\.java$</pattern>
<format>relative-path</format>
<arity>
<separated-files>,</separated-files>
</arity>
</context>
</action>
<action name="test">
<target>test</target>
</action>
</ide-actions>
<export>
<type>folder</type>
<location>build</location>
<build-target>compile</build-target>
</export>
<export>
<type>folder</type>
<location>build</location>
<build-target>compile</build-target>
</export>
<export>
<type>folder</type>
<location>test</location>
<build-target>compile</build-target>
</export>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-folder style="packages">
<label>test</label>
<location>test</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="rebuild"/>
<ide-action name="clean"/>
<ide-action name="test"/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="compile">lib;lib/diffutils-1.2.1.jar</classpath>
<built-to>build</built-to>
<source-level>1.6</source-level>
</compilation-unit>
<compilation-unit>
<package-root>test</package-root>
<unit-tests/>
<classpath mode="compile">build;lib/diffutils-1.2.1.jar;lib/diffutils-1.2.1-javadoc.jar;lib/diffutils-1.2.1-sources.jar;lib/junit-4.8.2.jar</classpath>
<built-to>build</built-to>
<built-to>test</built-to>
<source-level>1.6</source-level>
</compilation-unit>
</java-data>
<preferences xmlns="http://www.netbeans.org/ns/auxiliary-configuration-preferences/1">
<module name="org-netbeans-modules-html-editor-lib"/>
<module name="org-netbeans-modules-editor-indent">
<node name="CodeStyle">
<property name="usedProfile" value="project"/>
<node name="project">
<property name="spaces-per-tab" value="4"/>
<property name="tab-size" value="4"/>
<property name="indent-shift-width" value="4"/>
<property name="expand-tabs" value="false"/>
<property name="text-limit-width" value="80"/>
<property name="text-line-wrap" value="none"/>
</node>
</node>
<node name="text">
<node name="x-java">
<node name="CodeStyle">
<node name="project"/>
</node>
</node>
</node>
</module>
<module name="org-netbeans-modules-projectimport-eclipse-core"/>
</preferences>
</configuration>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>DataModel</name>
</general-data>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
<!-- Do not use Project Properties customizer when editing this file manually. -->
<name>DataModel</name>
<properties/>
<folders>
<source-folder>
<label>DataModel</label>
<location>.</location>
<encoding>windows-1252</encoding>
</source-folder>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
<encoding>windows-1252</encoding>
</source-folder>
<source-folder>
<label>test</label>
<type>java</type>
<location>test</location>
<encoding>windows-1252</encoding>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>dist</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>dist</target>
</action>
<action name="run.single">
<script>nbproject/ide-file-targets.xml</script>
<target>run-selected-file-in-test</target>
<context>
<property>run.class</property>
<folder>test</folder>
<pattern>\.java$</pattern>
<format>java-name</format>
<arity>
<one-file-only/>
</arity>
</context>
</action>
<action name="compile.single">
<script>nbproject/ide-file-targets.xml</script>
<target>compile-selected-files-in-test</target>
<context>
<property>files</property>
<folder>test</folder>
<pattern>\.java$</pattern>
<format>relative-path</format>
<arity>
<separated-files>,</separated-files>
</arity>
</context>
</action>
<action name="test">
<target>test</target>
</action>
</ide-actions>
<export>
<type>folder</type>
<location>build</location>
<build-target>compile</build-target>
</export>
<export>
<type>folder</type>
<location>build</location>
<build-target>compile</build-target>
</export>
<export>
<type>folder</type>
<location>test</location>
<build-target>compile</build-target>
</export>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-folder style="packages">
<label>test</label>
<location>test</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="rebuild"/>
<ide-action name="clean"/>
<ide-action name="test"/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="compile">lib;lib/diffutils-1.2.1.jar</classpath>
<built-to>build</built-to>
<source-level>1.6</source-level>
</compilation-unit>
<compilation-unit>
<package-root>test</package-root>
<unit-tests/>
<classpath mode="compile">build;lib/diffutils-1.2.1.jar;lib/diffutils-1.2.1-javadoc.jar;lib/diffutils-1.2.1-sources.jar;lib/junit-4.8.2.jar</classpath>
<built-to>build</built-to>
<built-to>test</built-to>
<source-level>1.6</source-level>
</compilation-unit>
</java-data>
<preferences xmlns="http://www.netbeans.org/ns/auxiliary-configuration-preferences/1">
<module name="org-netbeans-modules-html-editor-lib"/>
<module name="org-netbeans-modules-editor-indent">
<node name="CodeStyle">
<property name="usedProfile" value="project"/>
<node name="project">
<property name="spaces-per-tab" value="4"/>
<property name="tab-size" value="4"/>
<property name="indent-shift-width" value="4"/>
<property name="expand-tabs" value="false"/>
<property name="text-limit-width" value="80"/>
<property name="text-line-wrap" value="none"/>
</node>
</node>
<node name="text">
<node name="x-java">
<node name="CodeStyle">
<node name="project"/>
</node>
</node>
</node>
</module>
<module name="org-netbeans-modules-projectimport-eclipse-core"/>
</preferences>
</configuration>
</project>
......@@ -362,10 +362,18 @@ void
/**
* Revert all changes after the process has run sucessfully.
* @returns 1 on error, 0 on success
*/
int
TskAutoDb::revertAddImage()
{
if (m_imgTransactionOpen == false) {
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_AUTO_DB);
tsk_error_set_errstr("revertAddImage(): transaction is already closed");
return 1;
}
int retval = m_db->revertSavepoint(TSK_ADD_IMAGE_SAVEPOINT);
m_imgTransactionOpen = false;
return retval;
......@@ -373,13 +381,23 @@ int
/**
* Finish the process after it has run sucessfully by committing the changes.
* Returns the id of the image that was added.
* @returns Id of the image that was added or -1 on error
*/
int64_t
TskAutoDb::commitAddImage()
{
m_db->releaseSavepoint(TSK_ADD_IMAGE_SAVEPOINT);
if (m_imgTransactionOpen == false) {
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_AUTO_DB);
tsk_error_set_errstr("commitAddImage(): transaction is already closed");
return -1;
}
int retval = m_db->releaseSavepoint(TSK_ADD_IMAGE_SAVEPOINT);
m_imgTransactionOpen = false;
if (retval == 1) {
return -1;
}
return m_curImgId;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment