Bug fixes

This commit is contained in:
Eugene Livis 2016-01-08 13:49:26 -05:00
parent acc216b549
commit 8dc3288b0a
2 changed files with 11 additions and 1 deletions

View File

@ -131,7 +131,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
// write the vm file to output folder // write the vm file to output folder
try { try {
writeVirtualMachineToDisk(vmFile, outputFolderForThisVM); writeVirtualMachineToDisk(vmFile, outputFolderForThisVM);
} catch (IOException ex) { } catch (Exception ex) {
logger.log(Level.SEVERE, String.format("Failed to write virtual machine file %s (id=%d) to disk", vmFile.getName(), vmFile.getId()), ex); logger.log(Level.SEVERE, String.format("Failed to write virtual machine file %s (id=%d) to disk", vmFile.getName(), vmFile.getId()), ex);
MessageNotifyUtil.Notify.error("Failed to extract virtual machine file", String.format("Failed to write virtual machine file %s to disk", vmFile.getName())); MessageNotifyUtil.Notify.error("Failed to extract virtual machine file", String.format("Failed to write virtual machine file %s to disk", vmFile.getName()));
} }
@ -186,6 +186,12 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
private void writeVirtualMachineToDisk(AbstractFile vmFile, String outputFolderForThisVM) throws IOException { private void writeVirtualMachineToDisk(AbstractFile vmFile, String outputFolderForThisVM) throws IOException {
// TODO: check available disk space first // TODO: check available disk space first
// check if output folder exists
File destinationFolder = Paths.get(outputFolderForThisVM).toFile();
if (!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
/* /*
* Write the virtual machine file to disk. * Write the virtual machine file to disk.
*/ */

View File

@ -193,6 +193,10 @@ public final class VirtualMachineFinderUtility {
// only returns files, skips folders // only returns files, skips folders
File file = new File(path); File file = new File(path);
String[] files = file.list((File current, String name) -> new File(current, name).isFile()); String[] files = file.list((File current, String name) -> new File(current, name).isFile());
if (files == null) {
// null is returned when folder doesn't exist. need to check this condition, otherwise there is NullPointerException when converting to List
return Collections.emptyList();
}
return new ArrayList<>(Arrays.asList(files)); return new ArrayList<>(Arrays.asList(files));
} }
} }