Conversation
Summary of ChangesHello @Symb0x76, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在显著提升音乐导出功能的稳定性和用户体验。它通过解决音频文件解析逻辑的缺陷、优化外部 Python 进程调用的健壮性、增强文件系统路径名称的净化处理,以及引入导出目录的唯一性管理,全面提升了导出操作的成功率和可靠性,尤其是在处理包含特殊字符或复杂媒体资源的曲目时。 Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
此 PR 聚焦于提升谱面/maidata 导出稳定性与兼容性:修复音频资源解析在 cueId 与 musicId 不一致时的失败问题;将 WannaCRI(Python.Runtime)调用隔离到子进程以避免主进程崩溃;并在前端导出时加强目录/文件名净化与重名处理,减少 File System Access API 写入失败。
Changes:
- 音频解析:支持按候选 ID(
cueId/id/nonDxId)解析 ACB/AWB,并在失败时输出更明确的错误。 - 视频导出:WannaCRI 改为通过 helper 子进程执行,导出 pv.mp4 失败时降级跳过并记录 warning。
- 前端批量导出:新增分段净化(全角映射 + NFC)与同名目录唯一化逻辑,避免 “Name is not allowed” 与覆盖冲突。
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| MaiChartManager/WannaCRI/WannaCRI.cs | 新增 helper 子进程执行路径,避免 Python.Runtime 初始化/销毁导致崩溃 |
| MaiChartManager/Program.cs | 增加 --run-wannacri 分支作为 helper 入口 |
| MaiChartManager/Utils/AudioConvert.cs | 新增多候选音频解析与按 ACB/AWB 路径缓存 wav 的能力 |
| MaiChartManager/Controllers/Music/MusicTransferController.cs | 导出/打包时按候选 ID 解析音频;视频导出失败降级;加强源目录校验与错误信息 |
| MaiChartManager/Front/src/utils/sanitizeFsName.ts | 新增路径段净化工具(全角映射 + NFC + 去尾点/空白/控制字符) |
| MaiChartManager/Front/src/utils/getSubDirFile.ts | 写入前对每个路径段进行净化兜底,避免非法段名 |
| MaiChartManager/Front/src/components/MusicList/BatchActionButton/remoteExport.ts | 生成安全且唯一的导出目录名;增强 fetch/zip 读取错误处理 |
| .gitignore | 忽略 *.code-workspace |
| .github/workflows/build.yml | YAML 格式/缩进调整(功能不变) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MaiChartManager/Front/src/components/MusicList/BatchActionButton/remoteExport.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Code Review
This pull request addresses multiple critical issues in the export function, including audio parsing, BGA export crashes, and handling of illegal filenames and directory conflicts. A key architectural improvement is the isolation of WannaCRI Python calls into a subprocess, significantly enhancing stability and robustness. However, a high-severity path traversal vulnerability has been identified in the new filename sanitization logic within getSubDirFile.ts, which could allow directory traversal attacks using .. due to improper path segment sanitization. Additionally, the PR improves frontend handling of file and directory names for better compatibility and prevents overwriting of existing directories.
问题与解决办法
1. 音频解析失败(cueId 与 musicId 不一致)
现象: 部分曲目导出失败,日志显示找不到 ACB/AWB 或音频解析异常。
根因: 有些曲目使用
cueId指向其他音频资源,旧逻辑仅按musicId查找。解决办法
cueId解析音频,再回退musicId/nonDxId。2. 带 BGA 导出崩溃(Python Runtime 访问冲突)
现象: 导出到某些曲目时直接崩溃,日志常见
Fatal error 0xC0000005,堆栈落在Python.Runtime。根因: 主进程内反复
PythonEngine.Initialize/Shutdown在高频场景下不稳定。解决办法
pv.mp4转换失败时降级为"跳过视频并记录 warning/失败日志",不中断。3. 批量导出
Name is not allowedFailed to execute 'getDirectoryHandle' ... Name is not allowed。~相关曲目)时触发。remoteExport.ts在生成目录名时净化。getSubDirFile.ts在实际写入前再次逐段净化兜底。非法字符改为全角映射(不是简单下划线),保留歌名可读性:
/->/\\->\:->:*->*?->?"->"<-><>->>|->|Unicode 归一化由
NFKC调整为NFC,保留全角标点样式(例如~、!)。4. 导出目录重名冲突
现象: 同名曲或规范化后同名会互相覆盖。
根因: 目录名未做唯一化。
解决办法: 构建唯一目录映射,重名自动追加
(2)/(3)。