added support for cases when file info attrubutes are not available

This commit is contained in:
Eugene Livis 2014-10-20 13:18:50 -04:00
parent 057db6bb01
commit 46133acd77

View File

@ -284,12 +284,23 @@ public final class SevenZipIngestModule implements FileIngestModule {
if (detectedFormat == null) { if (detectedFormat == null) {
logger.log(Level.WARNING, "Could not detect format for file: " + archiveFile); //NON-NLS logger.log(Level.WARNING, "Could not detect format for file: " + archiveFile); //NON-NLS
// if we don't have attribute info then use file extension
String extension = archiveFile.getNameExtension();
if ("rar".equals(extension))
{
// for RAR files we need to open them explicitly as RAR. Otherwise, if there is a ZIP archive inside RAR archive
// it will be opened incorrectly when using 7zip's built-in auto-detect functionality
return RAR;
}
// Otherwise open the archive using 7zip's built-in auto-detect functionality
return null; return null;
} }
else if (detectedFormat.contains("application/x-rar-compressed")) else if (detectedFormat.contains("application/x-rar-compressed"))
{ {
// EL: for RAR files we need to open them explicitly as RAR. Otherwise, if there is a ZIP archive inside RAR archive // for RAR files we need to open them explicitly as RAR. Otherwise, if there is a ZIP archive inside RAR archive
// it will be opened incorrectly when using 7zip's built-in auto-detect functionality (see VIK-619). // it will be opened incorrectly when using 7zip's built-in auto-detect functionality
return RAR; return RAR;
} }
@ -339,8 +350,9 @@ public final class SevenZipIngestModule implements FileIngestModule {
try { try {
stream = new SevenZipContentReadStream(new ReadContentInputStream(archiveFile)); stream = new SevenZipContentReadStream(new ReadContentInputStream(archiveFile));
// EL: for RAR files we need to open them explicitly as RAR. Otherwise, if there is a ZIP archive inside RAR archive // for RAR files we need to open them explicitly as RAR. Otherwise, if there is a ZIP archive inside RAR archive
// it will be opened incorrectly when using 7zip's built-in auto-detect functionality (see VIK-619). // it will be opened incorrectly when using 7zip's built-in auto-detect functionality.
// All other archive formats are still opened using 7zip built-in auto-detect functionality.
ArchiveFormat options = get7ZipOptions(archiveFile); ArchiveFormat options = get7ZipOptions(archiveFile);
inArchive = SevenZip.openInArchive(options, stream); inArchive = SevenZip.openInArchive(options, stream);