Merge pull request #4695 from sleuthkit/release-4.11.0

Merge in release 4.11.0 branch
This commit is contained in:
Richard Cordovano 2019-04-09 09:29:35 -04:00 committed by GitHub
commit 1801304e00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 20 deletions

View File

@ -186,9 +186,8 @@ DeleteCaseTask.progress.acquiringManifestLocks=Acquiring exclusive manifest file
DeleteCaseTask.progress.connectingToCoordSvc=Connecting to the coordination service...
DeleteCaseTask.progress.deletingCaseDirCoordSvcNode=Deleting case directory znode...
DeleteCaseTask.progress.deletingCaseNameCoordSvcNode=Deleting case name znode...
# {0} - data source name
# {1} - device id
DeleteCaseTask.progress.deletingDataSource=Deleting data source {0} with device id {1}...
# {0} - data source path
DeleteCaseTask.progress.deletingDataSource=Deleting data source {0}...
DeleteCaseTask.progress.deletingJobLogLockNode=Deleting case auto ingest log znode...
# {0} - manifest file path
DeleteCaseTask.progress.deletingManifest=Deleting manifest file {0}...

View File

@ -591,12 +591,12 @@ final class DeleteCaseTask implements Runnable {
* otherwise.
*/
@NbBundle.Messages({
"# {0} - data source name", "# {1} - device id", "DeleteCaseTask.progress.deletingDataSource=Deleting data source {0} with device id {1}...",})
"# {0} - data source path", "DeleteCaseTask.progress.deletingDataSource=Deleting data source {0}..."
})
private boolean deleteDataSources(Manifest manifest, List<DataSource> dataSources) {
final String dataSourceFileName = manifest.getDataSourceFileName();
final String dataSourceDeviceId = manifest.getDeviceId();
progress.progress(Bundle.DeleteCaseTask_progress_deletingDataSource(dataSourceFileName, dataSourceDeviceId));
logger.log(Level.INFO, String.format("Deleting data source %s with device id %s from %s", dataSourceFileName, dataSourceDeviceId, caseNodeData.getDisplayName()));
final Path dataSourcePath = manifest.getDataSourcePath();
progress.progress(Bundle.DeleteCaseTask_progress_deletingDataSource(dataSourcePath));
logger.log(Level.INFO, String.format("Deleting data source %s from %s", dataSourcePath, caseNodeData.getDisplayName()));
/*
* There are two possibilities here. The data source may be an image,
@ -606,26 +606,48 @@ final class DeleteCaseTask implements Runnable {
* set, report file, archive file, etc.). In this case, just the file
* referenced by the manifest will be deleted.
*/
boolean allFilesDeleted = true;
Set<Path> filesToDelete = new HashSet<>();
for (DataSource dataSource : dataSources) {
int index = 0;
while (index < dataSources.size() && filesToDelete.isEmpty()) {
DataSource dataSource = dataSources.get(index);
if (dataSource instanceof Image) {
Image image = (Image) dataSource;
if (image.getName().equals(dataSourceFileName) && image.getDeviceId().equals(dataSourceDeviceId)) {
String[] imageFilePaths = image.getPaths();
/*
* Check for a match between one of the paths for the image
* files and the data source file path in the manifest.
*/
for (String imageFilePath : imageFilePaths) {
Path candidatePath = Paths.get(imageFilePath);
if (candidatePath.equals(dataSourcePath)) {
/*
* If a match is found, add all of the file paths for
* the image to the set of files to be deleted.
*/
for (String path : imageFilePaths) {
Path imageFilePath = Paths.get(path);
filesToDelete.add(imageFilePath);
filesToDelete.add(Paths.get(path));
}
break;
}
}
}
if (filesToDelete.isEmpty()) {
final Path dataSourcePath = manifest.getDataSourcePath();
filesToDelete.add(dataSourcePath);
++index;
}
/*
* At a minimum, the data source at the file path given in the manifest
* should be deleted. If the data source is not a disk image, this will
* be the path of an archive, a logical file, or a logical directory.
* TODO-4933: Currently, the contents extracted from an archive are not
* deleted, nor are any additional files associated with a report data
* source.
*/
filesToDelete.add(dataSourcePath);
/*
* Delete the file(s).
*/
boolean allFilesDeleted = true;
for (Path path : filesToDelete) {
File fileOrDir = path.toFile();
if (fileOrDir.exists() && !FileUtil.deleteFileDir(fileOrDir)) {