Skip to content

extractZIPArchive 存在空循环死代码#47

Merged
Svtter merged 2 commits into
mainfrom
ralph/issue-8
May 13, 2026
Merged

extractZIPArchive 存在空循环死代码#47
Svtter merged 2 commits into
mainfrom
ralph/issue-8

Conversation

@Svtter
Copy link
Copy Markdown
Contributor

@Svtter Svtter commented May 13, 2026

Problem

extractZIPArchive in internal/server/server.go contained a dead for range reader.File loop (lines 1162–1166) whose body only checked archivedFile.FileInfo().IsDir() and issued a bare continue — it never accumulated state, returned errors, or produced side effects. This was leftover dead code that added unnecessary iteration over every archive entry before the real extraction loop.

Approach

Removed the empty loop entirely (5 lines). The real validation and extraction logic in the second for range reader.File loop (archive count check, path normalization, directory creation, file extraction) is untouched and handles all necessary work.

Tests

  • Existing test suite (go test ./internal/server/...) covers extractZIPArchive and continues to pass — behavior is unchanged since the removed loop had no observable effect.

Closes #8

Agent added 2 commits May 13, 2026 18:29
The first for-range loop over reader.File only checked IsDir() and
continued without performing any work. Remove this dead code.

Closes #8
Prevent CI/tooling directories from being accidentally committed.
@github-actions
Copy link
Copy Markdown

无遗漏

Issue #8 的需求极其简单:删除 extractZIPArchive 中第一个无用的 for range 空循环。PR 完全实现了这一要求——删除了该循环(5 行),其余核心提取逻辑(文件数校验、路径归一化、路径逃逸检查、目录创建、文件写入)保持不变。.gitignore 的变更虽不在 issue 范围内,但不影响功能实现,也无遗漏。

New%20session%20-%202026-05-13T10%3A30%3A46.243Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown

可合并

审查总结

两个变更均干净、安全,无阻塞问题。

.gitignore — 功能强化

  • 新增 .serena/ 忽略规则,补充 .ralph/ 规则(将原 .ralph 改为 .ralph/,语义上从"匹配文件或目录"变为"仅匹配目录",但实际使用中这些均为目录,无影响)。

internal/server/server.go — 死代码移除

  • 删除了 extractZIPArchive 中一个纯空循环(for range reader.File 内仅 if IsDir() { continue }),该循环无任何副作用、无状态累积、无错误返回。真实的提取循环(第 1172–1219 行)已正确包含目录创建逻辑,不受影响。
  • 缩短了不必要的全量遍历,是纯收益的清理。

阻塞项:无

建议项:无

New%20session%20-%202026-05-13T10%3A30%3A55.845Z
opencode session  |  github run

@Svtter Svtter merged commit 7a4a149 into main May 13, 2026
4 checks passed
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.

extractZIPArchive 存在空循环死代码

1 participant