Exclude solid archives

This commit is contained in:
seven332 committed 2018-12-13 23:29:48 +08:00
1 parent 77fd0eb73e
commit b5f36dafdc
3 files changed
+17 -2

No files matched your search

+1 -1
View File
@@ -71,7 +71,7 @@ dependencies {
implementation 'com.github.seven332:android-resource:0.1.0'
implementation 'com.github.seven332:animator:0.1.0'
implementation 'com.github.seven332:beerbelly:0.1.4'
implementation 'com.github.seven332.commons-compress:android-lite:e4218388f6'
implementation 'com.github.seven332.commons-compress:android-lite:464e96d3b4'
implementation 'com.github.seven332:conaco:0.1.5-eh'
implementation 'com.github.seven332:drawerlayout:0.2.1'
implementation 'com.github.seven332:easyrecyclerview:0.1.1'
@@ -58,6 +58,9 @@ public class RarArchive extends Archive {
com.github.junrar.Archive archive;
try {
archive = new com.github.junrar.Archive(volumeManager);
if (archive.getMainHeader().isSolid()) {
throw new IOException("Solid archive is not supported");
}
} catch (RarException e) {
throw new IOException("Invalid rar archive", e);
}
@@ -38,7 +38,9 @@ public class SevenZArchive extends Archive {
List<ArchiveEntry> result = new ArrayList<>();
for (org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry archive : file.getEntries()) {
if (isSupportedFilename(archive.getName().toLowerCase())) {
if (archive.getSize() != 0
&& !archive.isDirectory()
&& isSupportedFilename(archive.getName().toLowerCase())) {
result.add(new SevenZArchiveEntry(file, archive));
}
}
@@ -54,6 +56,16 @@ public class SevenZArchive extends Archive {
public static Archive create(UniRandomAccessFile file) throws IOException {
Store store = new UniRandomAccessFileStore(file);
SevenZFile sevenZFile = new SevenZFile(store);
// Check whether the archive is solid
for (org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry entry : sevenZFile.getEntries()) {
if (entry.getSize() != 0
&& !entry.isDirectory()
&& !entry.isFirstInFolder()) {
throw new IOException("Solid archive is not supported");
}
}
return new SevenZArchive(sevenZFile);
}