fix(server): 修复服务端文件名编码与终端乱码问题#79
Conversation
|
⚠ 本 PR 已进入自动化语法检查流程,请稍后 本次变更文件 (3 个):
正在进行 TypeScript 语法检查... |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b15d7142e4
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // 确保目标目录存在 | ||
| await fs.mkdir(targetDir, { recursive: true }) | ||
| const tempBaseName = `.gsm3-zip-extract-${Date.now()}` |
There was a problem hiding this comment.
Use collision-resistant temp dirs for ZIP retries
extractZip builds retry directories from Date.now() plus a fixed index, so two extractZip calls started in the same millisecond under the same parent can pick identical temp paths and race on rm/mkdir/extract. In that case one request can delete or overwrite the other request’s in-progress extraction, leading to intermittent failures or corrupted output in concurrent production workloads.
Useful? React with 👍 / 👎.
| continue | ||
| } | ||
|
|
||
| await fs.copyFile(sourcePath, targetPath) |
There was a problem hiding this comment.
Preserve symlinks when merging extracted files
The new merge step copies every non-directory entry with fs.copyFile, which does not preserve symlinks; symlink-to-file entries become regular files and symlink-to-directory entries can throw EISDIR. This means ZIPs containing symlinks (common in Unix-oriented packages) may now fail to extract or silently lose link structure, a regression from the previous direct extraction path.
Useful? React with 👍 / 👎.
|
⚠ 本 PR 已进入自动化语法检查流程,请稍后 本次变更文件 (4 个):
正在进行 TypeScript 语法检查... |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b25819be7a
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (entry.isDirectory()) { | ||
| await mergeDirectoryContents(sourcePath, targetPath) | ||
| continue | ||
| } | ||
|
|
||
| await fs.copyFile(sourcePath, targetPath) |
There was a problem hiding this comment.
Preserve symlink entries when merging extracted files
mergeDirectoryContents treats every non-directory entry as a regular file and calls fs.copyFile, which dereferences file symlinks and throws EISDIR for directory symlinks. That means ZIPs containing symlinks can now fail during finalize, or silently lose symlink semantics by turning links into plain files, whereas direct extraction previously kept the extractor’s output intact.
Useful? React with 👍 / 👎.
| await mergeDirectoryContents(chosenTempDir, targetDir) | ||
| await fs.rm(chosenTempDir, { recursive: true, force: true }) |
There was a problem hiding this comment.
Avoid duplicating the whole extracted tree before returning
After a successful decode attempt, the code always copies the entire temporary extraction tree into targetDir and only then deletes the temp directory. This introduces a guaranteed second full I/O pass and transiently requires roughly double disk space, so large ZIPs that used to fit can now fail with ENOSPC during the copy stage.
Useful? React with 👍 / 👎.
|
@hengwuming 接下来我来修复剩余问题 |
我已经让gpt改好了 |
|
⚠ 本 PR 已进入自动化语法检查流程,请稍后 本次变更文件 (4 个):
正在进行 TypeScript 语法检查... |
好 我看下 |
关联问题
Closes #78
变更内容
�的损坏文件名验证
cd server && npm run buildcd server && npm test -- --runInBand说明