Skip to content

Feature: Decompress legacy HMCL log files while exporting.#4342

Merged
Glavo merged 5 commits intoHMCL-dev:mainfrom
burningtnt:fix/decompress-legacy-hmcl-log
Aug 27, 2025
Merged

Feature: Decompress legacy HMCL log files while exporting.#4342
Glavo merged 5 commits intoHMCL-dev:mainfrom
burningtnt:fix/decompress-legacy-hmcl-log

Conversation

@burningtnt
Copy link
Copy Markdown
Member

@burningtnt burningtnt commented Aug 26, 2025

No description provided.

@burningtnt burningtnt requested a review from Glavo August 26, 2025 14:28
@Glavo Glavo requested a review from Copilot August 27, 2025 13:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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);
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
tempChannel.truncate(0);
tempChannel.truncate(0);
tempChannel.position(0);

Copilot uses AI. Check for mistakes.
break decompress;
}

zos.putNextEntry(new ZipEntry(StringUtils.substringBeforeLast(FileUtils.getName(path), '.')));
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
zos.putNextEntry(new ZipEntry(StringUtils.substringBeforeLast(FileUtils.getName(path), '.')));
zos.putNextEntry(new ZipEntry(StringUtils.substringBeforeLast(FileUtils.getName(path), '.')));
tempChannel.position(0);

Copilot uses AI. Check for mistakes.
zos.closeEntry();
}

try {
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit d34dc82 into HMCL-dev:main Aug 27, 2025
2 checks passed
@burningtnt burningtnt deleted the fix/decompress-legacy-hmcl-log branch August 27, 2025 13:50
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.

3 participants