psiegman / epublib

a java library for reading and writing epub files
http://www.siegmann.nl/epublib
1.06k stars 317 forks source link

Loading a corrupt epub causes Android to freeze. #107

Closed ashleypeacock closed 7 years ago

ashleypeacock commented 7 years ago

Hi

Whenever a corrupted epub is loaded - Android freezes - and I don't get an exception thrown in order to handle the corrupt file.

I'm downloading an epub and then cutting out the wifi half way through so that only half is downloaded. When attempting to load this using the epub library, it freezes the app entirely - no crash.

   public EBook(String pathName) throws IOException {
            Book book = loadBook(pathName);
            this.title = book.getTitle();
            this.coverImage = BitmapFactory.decodeStream(book.getCoverImage().getInputStream());
            this.path = pathName;
            this.summary = book.getMetadata().getDescriptions().get(0);
    }

    public Book loadBook(String pathName) throws IOException {
            File file = new File(pathName);
            InputStream is = new FileInputStream(file);
            EpubReader reader = new EpubReader();
            return reader.readEpub(is);
    }

The code gets to the line reader.readEpub(is) and freezes?

Any help would be massively appreciated!

ashleypeacock commented 7 years ago

Update: I used the form epub library from NightWhistler's page turner. And used the readEpubLazy which helps to fix this issue.