Feature: Decompress legacy HMCL log files while exporting.#4342
Feature: Decompress legacy HMCL log files while exporting.#4342Glavo merged 5 commits intoHMCL-dev:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements decompression functionality for legacy HMCL log files during export. The implementation adds support for decompressing .gz and .xz compressed log files before including them in the exported zip archive.
Key Changes:
- Added decompression support for .gz and .xz log files during export
- Implemented temporary file handling for decompressed content
- Modified zip entry naming to remove compression extensions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| zos.putNextEntry(new ZipEntry(StringUtils.substringBeforeLast(FileUtils.getName(path), '.'))); | ||
| Channels.newInputStream(tempChannel).transferTo(zos); | ||
| zos.closeEntry(); | ||
| tempChannel.truncate(0); |
There was a problem hiding this comment.
The tempChannel position should be reset to 0 after truncation to ensure proper reading for subsequent iterations. Add tempChannel.position(0); after the truncate call.
| tempChannel.truncate(0); | |
| tempChannel.truncate(0); | |
| tempChannel.position(0); |
| break decompress; | ||
| } | ||
|
|
||
| zos.putNextEntry(new ZipEntry(StringUtils.substringBeforeLast(FileUtils.getName(path), '.'))); |
There was a problem hiding this comment.
The tempChannel position should be reset to 0 before creating the InputStream to read from the beginning of the temp file. Add tempChannel.position(0); before this line.
| zos.putNextEntry(new ZipEntry(StringUtils.substringBeforeLast(FileUtils.getName(path), '.'))); | |
| zos.putNextEntry(new ZipEntry(StringUtils.substringBeforeLast(FileUtils.getName(path), '.'))); | |
| tempChannel.position(0); |
| zos.closeEntry(); | ||
| } | ||
|
|
||
| try { |
There was a problem hiding this comment.
Consider using try-with-resources for the tempFile to ensure automatic cleanup, or move the deletion to a finally block to guarantee cleanup even if an exception occurs during zip creation.
No description provided.