Skip to content

Commit

Permalink
[Issue #173] Fix loading the first image from a 7zip encoded archive. (
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpierce committed Mar 18, 2020
1 parent 547fa85 commit 840240e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Expand Up @@ -59,10 +59,11 @@ public abstract class AbstractArchiveAdaptor<I> implements ArchiveAdaptor, Initi
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired protected FileTypeIdentifier fileTypeIdentifier;
@Autowired protected ComicInfoEntryAdaptor comicInfoEntryAdaptor;
protected List<EntryLoaderForType> loaders = new ArrayList<>();
protected Map<String, EntryLoader> entryLoaders = new HashMap<>();
@Autowired private ApplicationContext context;
@Autowired private ComicFileHandler comicFileHandler;

protected List<EntryLoaderForType> loaders = new ArrayList<>();
protected Map<String, EntryLoader> entryLoaders = new HashMap<>();
private String defaultExtension;

public AbstractArchiveAdaptor(String defaultExtension) {
Expand Down Expand Up @@ -283,8 +284,8 @@ protected File validateFile(Comic comic) throws ArchiveAdaptorException {
public String getFirstImageFileName(String filename) throws ArchiveAdaptorException {
I archiveRef = this.openArchive(new File(filename));

// get the list of entries
List<String> entries = this.getEntryFilenames(archiveRef);
Collections.sort(entries);
String result = null;

for (String entry : entries) {
Expand Down
Expand Up @@ -121,6 +121,7 @@ protected void loadAllFiles(Comic comic, SevenZFile archiveReference)
protected byte[] loadSingleFileInternal(SevenZFile archiveReference, String entryName)
throws ArchiveAdaptorException {
byte[] result = null;

try {
boolean done = false;
SevenZArchiveEntry entry = archiveReference.getNextEntry();
Expand Down
Expand Up @@ -112,6 +112,6 @@ public void testLoadSingleFile() throws ArchiveAdaptorException {

@Test
public void testGetFirstImageFileName() throws ArchiveAdaptorException {
assertEquals(TEST_FILE_ENTRY_1, archiveAdaptor.getFirstImageFileName(TEST_CBR_FILE));
assertEquals(TEST_FILE_ENTRY_0, archiveAdaptor.getFirstImageFileName(TEST_CBR_FILE));
}
}
Expand Up @@ -35,16 +35,16 @@
@SpringBootTest(classes = ComiXedTestContext.class)
@TestPropertySource(locations = "classpath:application.properties")
public class SevenZipArchiveAdaptorTest {
private static final String TEST_FILE_ENTRY_3 = "exampleCBR.jpg";
private static final String TEST_FILE_ENTRY_2 = "example.png";
private static final String TEST_FILE_ENTRY_2 = "exampleCBR.jpg";
private static final String TEST_FILE_ENTRY_3 = "example.png";
private static final String TEST_FILE_ENTRY_1 = "example.jpg";
private static final String TEST_FILE_ENTRY_0 = "example.jpeg";
private static final String TEST_CB7_FILE = "target/test-classes/example.cb7";
private static final String TEST_CBR_FILE = "target/test-classes/example.cbr";
private static final Object TEST_FILE_ENTRY_RENAMED_0 = "offset-000.jpeg";
private static final Object TEST_FILE_ENTRY_RENAMED_1 = "offset-001.jpg";
private static final Object TEST_FILE_ENTRY_RENAMED_2 = "offset-002.png";
private static final Object TEST_FILE_ENTRY_RENAMED_3 = "offset-003.jpg";
private static final Object TEST_FILE_ENTRY_RENAMED_2 = "offset-002.jpg";
private static final Object TEST_FILE_ENTRY_RENAMED_3 = "offset-003.png";

@Autowired private SevenZipArchiveAdaptor archiveAdaptor;

Expand Down
Binary file modified comixed-library/src/test/resources/example.cb7
Binary file not shown.

0 comments on commit 840240e

Please sign in to comment.