8000 Hang on viewing epub · Issue #57 · wustho/epy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Hang on viewing epub #57
Open
Open
@meganleewebb

Description

@meganleewebb

Version: v2022.2.14

epy loads the epub file, but hangs after the first page.

Problem is in (734-754):

    def get_raw_text(self, content_path: Union[str, ET.Element]) -> str:
        assert isinstance(self.file, zipfile.ZipFile)
        assert isinstance(content_path, str)

        max_tries: Optional[int] = None  # 1 if DEBUG else None

        # use try-except block to catch
        # zlib.error: Error -3 while decompressing data: invalid distance too far back
        # seems like caused by multiprocessing
        tries = 0
        while True:
            try:
                content = self.file.open(content_path).read()
                break
            except Exception as e:
                tries += 1
                if max_tries is not None and tries >= max_tries:
                    raise e

        return content.decode("utf-8")

when it is passed a content_path with value: "OEBPS/../jacket.xhtml"

self.file.open(content_path) errors with There is no item named 'OEBPS/../jacket.xhtml' in the archive"
The try/except catches the error.
max_tries = None
The while loop never exits.

My quick fix has been to set max_tries = 2
and add:

content_path=os.path.relpath(content_path)
after the tries += 1 line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0