Skip to content
Snippets Groups Projects
Unverified Commit 3bc97453 authored by eugene7646's avatar eugene7646 Committed by GitHub
Browse files

Merge pull request #2836 from gdicristofaro/7121-openFiles

7121 open files
parents 393247bc f9f76648
No related branches found
No related tags found
No related merge requests found
...@@ -10066,34 +10066,50 @@ public List<Image> getImages() throws TskCoreException { ...@@ -10066,34 +10066,50 @@ public List<Image> getImages() throws TskCoreException {
* within tsk core and the update fails * within tsk core and the update fails
*/ */
public void setImagePaths(long obj_id, List<String> paths) throws TskCoreException { public void setImagePaths(long obj_id, List<String> paths) throws TskCoreException {
CaseDbConnection connection = null; CaseDbTransaction transaction = beginTransaction();
acquireSingleUserCaseWriteLock();
PreparedStatement statement;
try { try {
connection = connections.getConnection(); setImagePaths(obj_id, paths, transaction);
connection.beginTransaction(); transaction.commit();
statement = connection.getPreparedStatement(PREPARED_STATEMENT.DELETE_IMAGE_NAME); transaction = null;
} finally {
if (transaction != null) {
transaction.rollback();
}
}
}
/**
* Set the file paths for the image given by obj_id
*
* @param obj_id the ID of the image to update
* @param paths the fully qualified path to the files that make up the
* image
* @param trans The case database transaction.
*
* @throws TskCoreException exception thrown when critical error occurs
* within tsk core and the update fails
*/
@Beta
public void setImagePaths(long obj_id, List<String> paths, CaseDbTransaction trans) throws TskCoreException {
try {
PreparedStatement statement = trans.getConnection().getPreparedStatement(PREPARED_STATEMENT.DELETE_IMAGE_NAME);
statement.clearParameters(); statement.clearParameters();
statement.setLong(1, obj_id); statement.setLong(1, obj_id);
connection.executeUpdate(statement); trans.getConnection().executeUpdate(statement);
for (int i = 0; i < paths.size(); i++) { for (int i = 0; i < paths.size(); i++) {
statement = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_IMAGE_NAME); statement = trans.getConnection().getPreparedStatement(PREPARED_STATEMENT.INSERT_IMAGE_NAME);
statement.clearParameters(); statement.clearParameters();
statement.setLong(1, obj_id); statement.setLong(1, obj_id);
statement.setString(2, paths.get(i)); statement.setString(2, paths.get(i));
statement.setLong(3, i); statement.setLong(3, i);
connection.executeUpdate(statement); trans.getConnection().executeUpdate(statement);
} }
connection.commitTransaction();
} catch (SQLException ex) { } catch (SQLException ex) {
rollbackTransaction(connection);
throw new TskCoreException("Error updating image paths.", ex); throw new TskCoreException("Error updating image paths.", ex);
} finally { }
closeConnection(connection);
releaseSingleUserCaseWriteLock();
}
} }
/** /**
* Deletes a datasource from the open case, the database has foreign keys * Deletes a datasource from the open case, the database has foreign keys
* with a delete cascade so that all the tables that have a datasource * with a delete cascade so that all the tables that have a datasource
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment