Merge pull request #5905 from APriestman/6324_removeLocking2

6324 Remove locking around adding image.
This commit is contained in:
Richard Cordovano 2020-05-20 15:40:57 -04:00 committed by GitHub
commit bb764aa5e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 53 deletions

View File

@ -146,8 +146,7 @@ final class AddRawImageTask implements Runnable {
return;
}
imageFilePaths.add(imageFilePath);
try {
caseDatabase.acquireSingleUserCaseWriteLock();
try {
/*
* Get Image that will be added to case
*/
@ -187,9 +186,6 @@ final class AddRawImageTask implements Runnable {
errorMessages.add(errorMessage);
logger.log(Level.SEVERE, errorMessage, ex);
criticalErrorOccurred = true;
} finally {
caseDatabase.releaseSingleUserCaseWriteLock();
}
}
}

View File

@ -116,30 +116,25 @@ class AddMultipleImagesTask implements Runnable {
* Try to add the input image files as images.
*/
List<String> corruptedImageFilePaths = new ArrayList<>();
try {
currentCase.getSleuthkitCase().acquireSingleUserCaseWriteLock();
progressMonitor.setIndeterminate(true);
for (String imageFilePath : imageFilePaths) {
synchronized (tskAddImageProcessLock) {
if (!tskAddImageProcessStopped) {
addImageProcess = currentCase.getSleuthkitCase().makeAddImageProcess(timeZone, false, false, "");
} else {
return;
}
}
run(imageFilePath, corruptedImageFilePaths, errorMessages);
commitOrRevertAddImageProcess(imageFilePath, errorMessages, newDataSources);
synchronized (tskAddImageProcessLock) {
if (tskAddImageProcessStopped) {
errorMessages.add(Bundle.AddMultipleImagesTask_cancelled());
result = DataSourceProcessorResult.CRITICAL_ERRORS;
newDataSources = emptyDataSources;
return;
}
progressMonitor.setIndeterminate(true);
for (String imageFilePath : imageFilePaths) {
synchronized (tskAddImageProcessLock) {
if (!tskAddImageProcessStopped) {
addImageProcess = currentCase.getSleuthkitCase().makeAddImageProcess(timeZone, false, false, "");
} else {
return;
}
}
run(imageFilePath, corruptedImageFilePaths, errorMessages);
commitOrRevertAddImageProcess(imageFilePath, errorMessages, newDataSources);
synchronized (tskAddImageProcessLock) {
if (tskAddImageProcessStopped) {
errorMessages.add(Bundle.AddMultipleImagesTask_cancelled());
result = DataSourceProcessorResult.CRITICAL_ERRORS;
newDataSources = emptyDataSources;
return;
}
}
} finally {
currentCase.getSleuthkitCase().releaseSingleUserCaseWriteLock();
}
/*
@ -153,8 +148,6 @@ class AddMultipleImagesTask implements Runnable {
try {
progressMonitor.setProgressText(Bundle.AddMultipleImagesTask_addingFileAsLogicalFile(corruptedImageFilePaths.toString()));
caseDatabase.acquireSingleUserCaseWriteLock();
Image dataSource = caseDatabase.addImageInfo(0, corruptedImageFilePaths, timeZone);
newDataSources.add(dataSource);
List<TskFileRange> fileRanges = new ArrayList<>();
@ -177,8 +170,6 @@ class AddMultipleImagesTask implements Runnable {
} catch (TskCoreException ex) {
errorMessages.add(Bundle.AddMultipleImagesTask_errorAddingImgWithoutFileSystem(deviceId, ex.getLocalizedMessage()));
criticalErrorOccurred = true;
} finally {
caseDatabase.releaseSingleUserCaseWriteLock();
}
}

View File

@ -146,30 +146,25 @@ final class AddMemoryImageTask implements Runnable {
progressMonitor.setProgressText(Bundle.AddMemoryImageTask_progressMessage_addingImageFile( memoryImagePath));
SleuthkitCase caseDatabase = Case.getCurrentCaseThrows().getSleuthkitCase();
caseDatabase.acquireSingleUserCaseWriteLock();
try {
/*
* Verify the memory image file exists.
*/
File imageFile = Paths.get(memoryImagePath).toFile();
if (!imageFile.exists()) {
throw new TskCoreException(Bundle.AddMemoryImageTask_exceptionMessage_noImageFile(memoryImagePath, deviceId));
}
/*
* Add the data source.
*
* NOTE: The object id for device passed to
* SleuthkitCase.addImageInfo is hard-coded to zero for now. This
* will need to be changed when a Device abstraction is added to the
* SleuthKit data model.
*/
Image dataSource = caseDatabase.addImageInfo(0, new ArrayList<>(Arrays.asList(memoryImagePath)), timeZone);
return dataSource;
} finally {
caseDatabase.releaseSingleUserCaseWriteLock();
/*
* Verify the memory image file exists.
*/
File imageFile = Paths.get(memoryImagePath).toFile();
if (!imageFile.exists()) {
throw new TskCoreException(Bundle.AddMemoryImageTask_exceptionMessage_noImageFile(memoryImagePath, deviceId));
}
/*
* Add the data source.
*
* NOTE: The object id for device passed to
* SleuthkitCase.addImageInfo is hard-coded to zero for now. This
* will need to be changed when a Device abstraction is added to the
* SleuthKit data model.
*/
Image dataSource = caseDatabase.addImageInfo(0, new ArrayList<>(Arrays.asList(memoryImagePath)), timeZone);
return dataSource;
}
/**