Skip to content

feat: 带启动器的压缩包含 .mrpack 时自动提取并作为 MR 整合包安装 - #3446

Closed
LuLu-ling wants to merge 2 commits into
devfrom
feat/fk-u-InstallPackLauncherPack
Closed

feat: 带启动器的压缩包含 .mrpack 时自动提取并作为 MR 整合包安装#3446
LuLu-ling wants to merge 2 commits into
devfrom
feat/fk-u-InstallPackLauncherPack

Conversation

@LuLu-ling

@LuLu-ling LuLu-ling commented Jul 22, 2026

Copy link
Copy Markdown
Member

此 PR 旨在使打包了启动器且包含 .mrpack 的整合包绕过问题重重的 InstallPackLauncherPack 方法直接提取 .mrpack 并作为正常的 MR 整合包进行安装(modpack.zip 因为无法完整确定其具体情况不敢贸然进行修改故仍然保持原样)

Summary by Sourcery

增强功能:

  • 在启动器包中将对 modpack.zip 的检测与对 modpack.mrpack 的检测分离,当存在 modpack.mrpack 时,直接采用正常的 MR 整合包安装流程进行短路处理。
Original summary in English

Summary by Sourcery

Enhancements:

  • Separate detection of modpack.zip from modpack.mrpack in launcher bundles and short-circuit to normal MR modpack installation when a modpack.mrpack is present.

@LuLu-ling
LuLu-ling requested a review from a team July 22, 2026 12:23
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: S PR 大小评估:小型 labels Jul 22, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
审阅者指南(在小型 PR 上折叠)

审阅者指南

此 PR 更改了整合包(modpack)检测逻辑:对于同时包含启动器和 modpack.mrpack 文件的压缩包,不再将其视为“启动器整合包”(launcher bundle),而是将其中的 .mrpack 提取到一个临时文件,并通过常规 MR 整合包安装路径进行安装,同时保持对 modpack.zip 的处理方式不变。

更新后的 ModpackInstall 处理嵌入式 modpack.mrpack 的流程图

flowchart TD
    A[ModpackInstall file] --> B[Open archive]
    B --> C{Archive contains modpack.zip?}
    C -->|Yes| D[set packType 9 for launcher_bundle]
    C -->|No| E{Archive contains modpack.mrpack?}
    E -->|Yes| F[Path.Combine Paths.Temp, Guid.NewGuid plus .mrpack]
    F --> G[ExtractToFile tempFile, overwrite true]
    G --> H[ModpackInstall tempFile and return]
    E -->|No| I[Continue existing pack type detection]
Loading

文件级更改

更改 细节 文件
通过将嵌入的 modpack.mrpack 提取到临时文件并委托给标准 ModpackInstall 流程,将这类压缩包视为普通 MR 整合包,而不是将其分类为启动器整合包(launcher bundle)。
  • 拆分对 modpack.zip 和 modpack.mrpack 的联合检测,使得只有 modpack.zip 会在根目录级压缩包扫描中设置 packType=9(launcher bundle)。
  • 为根目录级的 modpack.mrpack 添加条件处理:将该条目提取到 Paths.Temp 下的临时 .mrpack 文件中,使用基于 GUID 的文件名,并立即返回 ModpackInstall(tempFile)。
  • 拆分对 modpack.zip 和 modpack.mrpack 的联合检测,使得只有 modpack.zip 会在子目录级压缩包扫描中设置 packType=9(launcher bundle)。
  • 为子目录级的 modpack.mrpack 添加条件处理:将该条目提取到临时 .mrpack 文件,并立即返回 ModpackInstall(tempFile),跳过启动器整合包的安装流程。
Plain Craft Launcher 2/Modules/Minecraft/ModModpack.cs

可能关联的问题


提示与命令

与 Sourcery 交互

  • 触发新的审阅: 在拉取请求(pull request)上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub issue: 通过回复审阅评论,让 Sourcery 从该评论创建一个 issue。你也可以在审阅评论中回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题中任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,在任何时候(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中任意位置写上 @sourcery-ai summary,即可在该位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,在任何时候(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求上评论 @sourcery-ai guide,即可在任何时候(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求上评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不再想看到它们,这会很有用。
  • 忽略所有 Sourcery 审阅: 在拉取请求上评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审阅。特别适用于你想从一个全新的审阅开始——别忘了再评论 @sourcery-ai review 来触发新的审阅!

自定义你的使用体验

访问你的控制面板 来:

  • 启用或禁用审阅功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、移除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR changes the modpack detection logic so that archives containing a launcher and a modpack.mrpack file are no longer treated as "launcher bundles" but instead have the .mrpack extracted to a temp file and installed using the regular MR modpack installation path, while keeping modpack.zip handling unchanged.

Flow diagram for updated ModpackInstall handling of embedded modpack.mrpack

flowchart TD
    A[ModpackInstall file] --> B[Open archive]
    B --> C{Archive contains modpack.zip?}
    C -->|Yes| D[set packType 9 for launcher_bundle]
    C -->|No| E{Archive contains modpack.mrpack?}
    E -->|Yes| F[Path.Combine Paths.Temp, Guid.NewGuid plus .mrpack]
    F --> G[ExtractToFile tempFile, overwrite true]
    G --> H[ModpackInstall tempFile and return]
    E -->|No| I[Continue existing pack type detection]
Loading

File-Level Changes

Change Details Files
Treat archives with embedded modpack.mrpack as normal MR modpacks by extracting the .mrpack to a temp file and delegating to the standard ModpackInstall flow, instead of classifying them as launcher bundles.
  • Split combined detection of modpack.zip and modpack.mrpack so that only modpack.zip sets packType=9 (launcher bundle) in the root-level archive scan.
  • Add conditional handling for root-level modpack.mrpack: extract the entry to a temporary .mrpack file under Paths.Temp using a GUID-based filename and immediately return ModpackInstall(tempFile).
  • Split combined detection of modpack.zip and modpack.mrpack so that only modpack.zip sets packType=9 (launcher bundle) in the subdirectory-level archive scan.
  • Add conditional handling for subdirectory-level modpack.mrpack: extract the entry to a temporary .mrpack file and immediately return ModpackInstall(tempFile), bypassing launcher-pack installation.
Plain Craft Launcher 2/Modules/Minecraft/ModModpack.cs

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

嗨,我在这里给出了一些总体反馈:

  • .mrpack 的解压逻辑在根目录检查和一级子目录检查中都有重复;建议将这部分逻辑抽取成一个小的辅助方法,以减少重复并保持行为的一致性。
  • 在写入临时 .mrpack 文件时,建议使用作用域清理机制(例如在 ModpackInstall 完成后删除该临时文件),以避免在 Paths.Temp 中留下未使用的文件。
给 AI 代理的提示
请根据本次代码审查中的评论进行修改:

## 总体评论
- `.mrpack` 的解压逻辑在根目录检查和一级子目录检查中都有重复;建议将这部分逻辑抽取成一个小的辅助方法,以减少重复并保持行为的一致性。
- 在写入临时 `.mrpack` 文件时,建议使用作用域清理机制(例如在 `ModpackInstall` 完成后删除该临时文件),以避免在 `Paths.Temp` 中留下未使用的文件。

Sourcery 对开源项目免费——如果你觉得我们的审查有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续审查。
Original comment in English

Hey - I've left some high level feedback:

  • The .mrpack extraction logic is duplicated in both the root and first-level directory checks; consider factoring this into a small helper method to reduce repetition and keep behavior consistent.
  • When writing the temporary .mrpack file, consider using a scoped cleanup mechanism (e.g., deleting the temp file after ModpackInstall completes) to avoid leaving unused files in Paths.Temp.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `.mrpack` extraction logic is duplicated in both the root and first-level directory checks; consider factoring this into a small helper method to reduce repetition and keep behavior consistent.
- When writing the temporary `.mrpack` file, consider using a scoped cleanup mechanism (e.g., deleting the temp file after `ModpackInstall` completes) to avoid leaving unused files in `Paths.Temp`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71b762fd44

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Plain Craft Launcher 2/Modules/Minecraft/ModModpack.cs Outdated
Comment thread Plain Craft Launcher 2/Modules/Minecraft/ModModpack.cs Outdated
@LuLu-ling LuLu-ling closed this Jul 22, 2026
@pcl-ce-automation pcl-ce-automation Bot removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: S PR 大小评估:小型 labels Jul 22, 2026
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