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

Closed
wants to merge 1 commit into from
Closed

Zip file is not closed properly #1547

wants to merge 1 commit into from

Conversation

Kamik423
Copy link
Contributor

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.

Copy link
Member

@rdeltour rdeltour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @Kamik423, and sorry for the late review.

I'll do a little cleanup when merging with little tweaks (mostly for cosmetics, but also to call the close() method in a finally block). But otherwise looks good to me!

@rdeltour
Copy link
Member

Rebased and applied as 96a6e1c

@rdeltour rdeltour closed this Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready for review type: improvement The issue suggests an improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants