Repository navigation
Filesystem 48490: Unzip keeps the ZIP-file open after extracting - #12204
Merged
Merged
Conversation
Unzip kept the passed stream and the ZipArchive open for its whole lifetime. Consumers which delete the ZIP-file or its directory in the same scope after extract() (e.g. the test import) failed on file systems like NFS, where open files can not be removed. - only the path of the passed stream is kept, so a stream created just for the Unzip is closed immediately - extract() releases the archive in any case - new close() for consumers which only read paths or streams - the archive is reopened if it is accessed after it has been closed - the result of ZipArchive::open() is checked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the cause of https://mantis.ilias.de/view.php?id=48490 in the Filesystem component and replaces #12197.
Unzipkept the passed stream (usuallyStreams::ofResource(fopen(...))) and theZipArchiveopen for its whole lifetime. Consumers which delete the ZIP-file or its directory in the same scope afterextract()(e.g. the test import inilObjTestGUI::importFile()) fail on file systems like NFS, where open files can not be removed. Two file handles on the ZIP-file stayed open afterextract()and were only released when theUnzipobject was destroyed.Changes in
Unzip:Unzipis closed immediately. Streams held by the consumer are not closed.extract()releases the archive in any case (also for unreadable or rejected archives), inFLAT_STRUCTUREmode every entry stream is closed after writing it.close()for consumers which only read paths or streams.ZipAdaptercallsgetFiles()afterextract()).ZipArchive::open()is checked instead of relying oncount()throwing for unopened archives.This fixes the issue for all consumers of
Unzip, so no changes in the Test component are needed.Tests:
UnzipTestnow counts the open file handles of the process and ensures that none are left afterextract()(for all directory handlings, rejected archives and unreadable files), that the ZIP-file and its directory can be deleted while theUnzipis still in scope, that consumer streams stay open, that the archive is reopened on access and thatclose()is idempotent. The new handle tests fail without the fix.