Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zip file is not closed properly #1547

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Zip file is not closed properly #1547

wants to merge 1 commit into from

Conversation

Kamik423
Copy link

For checking the contents of an EPUB, a java.util.zip.ZipFile-object is created. This opens the file for introspection. The file can be closed in two different ways: By explicitly being closed once epubcheck is done with it (calling the .close() method), which is not done in this case; or by waiting for the garbage collection to clean up the object which results in a close as well. The latter is what happens in epubcheck. However there is no guarantee when Java runs the garbage collection, it could after hours. If epubcheck is integrated into another long running process, this can block EPUB file for quite a long time – during which it can not be deleted or overwritten.

I have implemented a fix for this, storing the ZipFile in the state object and closing it once all checks have been performed. The ZipFile object is still required to be open for checking all the resources during the process so it cannot just be closed at the end of the checkContainerStructure(···) method.

A merge would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant