From f87b0c6c4f998343def12c969dae24ee8bd27859 Mon Sep 17 00:00:00 2001 From: apriestman <apriestman@basistech.com> Date: Wed, 15 Apr 2020 11:46:59 -0400 Subject: [PATCH] Don't make unnecessary VirtualDirectory object. Cleanup. --- bindings/java/jni/auto_db_java.cpp | 4 ++-- bindings/java/jni/dataModel_SleuthkitJNI.cpp | 2 -- .../org/sleuthkit/datamodel/JniDbHelper.java | 3 +-- .../sleuthkit/datamodel/SleuthkitCase.java | 21 ++++++------------- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/bindings/java/jni/auto_db_java.cpp b/bindings/java/jni/auto_db_java.cpp index 8fb5b158e..09bc0400a 100644 --- a/bindings/java/jni/auto_db_java.cpp +++ b/bindings/java/jni/auto_db_java.cpp @@ -391,7 +391,7 @@ TskAutoDbJava::addFsInfo(const TSK_FS_INFO* fs_info, int64_t parObjId, return TSK_ERR; } - // Save the file system info for created unallocated blocks later + // Save the file system info for creating unallocated blocks later TSK_DB_FS_INFO fs_info_db; fs_info_db.objId = objId; fs_info_db.imgOffset = fs_info->offset; @@ -625,7 +625,7 @@ TskAutoDbJava::addFile(TSK_FS_FILE* fs_file, fs_file->name->type, meta_type, fs_file->name->flags, meta_flags, size, (unsigned long long)crtime, (unsigned long long)ctime, (unsigned long long) atime, (unsigned long long) mtime, - meta_mode, gid, uid, // md5TextPtr, known, + meta_mode, gid, uid, pathj, extj); objId = (int64_t)objIdj; diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp index 990f7608b..5ce1cfc39 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp +++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp @@ -1107,8 +1107,6 @@ JNIEXPORT void JNICALL uint8_t ret = 0; if ( (ret = tskAuto->startAddImage((int) numImgs, imagepaths8, TSK_IMG_TYPE_DETECT, 0, device_id)) != 0) { - printf("runOpenAndAddImgNat - startAddImage finished with errors\n"); - fflush(stdout); stringstream msgss; msgss << "Errors occurred while ingesting image " << std::endl; vector<TskAuto::error_record> errors = tskAuto->getErrorList(); diff --git a/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java b/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java index ae102db98..9efb3f058 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java +++ b/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java @@ -392,8 +392,7 @@ long addUnallocFsBlockFilesParent(long fsObjId, String name) { logger.log(Level.SEVERE, "Error - root directory for file system ID {0} not found", fsObjId); return -1; } - VirtualDirectory dir = caseDb.addVirtualDirectoryJNI(fsIdToRootDir.get(fsObjId), name, trans); - return dir.getId(); + return caseDb.addVirtualDirectoryJNI(fsIdToRootDir.get(fsObjId), name, trans); } catch (TskCoreException ex) { logger.log(Level.SEVERE, "Error creating virtual directory " + name + " under file system ID " + fsObjId, ex); return -1; diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index 1f8f94bde..d9b56ecdc 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -11295,25 +11295,18 @@ void addLayoutFileRangeJNI(long objId, long byteStart, long byteLen, /** * Adds a virtual directory to the database and returns a VirtualDirectory * object representing it. - * - * Make sure the connection in transaction is used for all database - * interactions called by this method + * For use with the JNI callbacks associated with the add image process. * * @param parentId the ID of the parent, or 0 if NULL * @param directoryName the name of the virtual directory to create * @param transaction the transaction in the scope of which the operation * is to be performed, managed by the caller * - * @return a VirtualDirectory object representing the one added to the - * database. - * + * @return The object ID of the new virtual directory + * * @throws TskCoreException */ - public VirtualDirectory addVirtualDirectoryJNI(long parentId, String directoryName, CaseDbTransaction transaction) throws TskCoreException { - if (transaction == null) { - throw new TskCoreException("Passed null CaseDbTransaction"); - } - + long addVirtualDirectoryJNI(long parentId, String directoryName, CaseDbTransaction transaction) throws TskCoreException { acquireSingleUserCaseWriteLock(); ResultSet resultSet = null; try { @@ -11404,10 +11397,8 @@ public VirtualDirectory addVirtualDirectoryJNI(long parentId, String directoryNa //extension, since this is not really file we just set it to null statement.setString(20, null); connection.executeUpdate(statement); - - return new VirtualDirectory(this, newObjId, dataSourceObjectId, directoryName, dirType, - metaType, dirFlag, metaFlags, null, FileKnown.UNKNOWN, - parentPath); + + return newObjId; } catch (SQLException e) { throw new TskCoreException("Error creating virtual directory '" + directoryName + "'", e); } finally { -- GitLab