【架构优化】从 recentDeckPathsIn 中拆出临时目录扫描 tempDirDeckFiles 与时间窗口过滤 filterRecentRegularFiles
維護者通常 1 天內回覆
評估
研究方向
Start in internal/httpapi/assistant_workbench.go at recentDeckPathsIn, which mixes workspace collection, the os.TempDir() scan with its early return uniquePaths(out), and the time-window filter. The proposed split is tempDirDeckFiles and filterRecentRegularFiles, and the existing read-failure branch must keep its current behaviour. Done means new unit tests for both helpers pass alongside go test ./internal/httpapi/. Pull request #477 is already open against this issue, so check it before starting any work.
由索引模型根據 Issue 內容生成。
描述
现状问题
internal/httpapi/assistant_workbench.go 中的 recentDeckPathsIn 约 40 行,同时做了三件事:
- 收集工作区
ws/、home/tmp/下的 pptx; - 扫描系统临时目录(
os.TempDir())下的 pptx 文件,以及名字含 ppt/slide/loopforge 的子目录; - 去重后按修改时间窗口(
since-30s~until)过滤出“新生成”的文件。
其中临时目录扫描分支还带有一个提前 return uniquePaths(out) 的出口,让读者需要来回比对两个返回路径;时间窗口过滤也无法单独测试。
重构方案
- 拆出
tempDirDeckFiles() ([]string, error):只负责扫描系统临时目录,读目录失败返回错误; - 拆出
filterRecentRegularFiles(paths []string, since, until time.Time) []string:只负责“常规文件 + 时间窗口”过滤; recentDeckPathsIn只做组合:收集候选 →uniquePaths→ 时间过滤。
影响范围
仅 internal/httpapi/assistant_workbench.go 内部未导出函数,对外接口与行为不变。
注意:原实现在读临时目录失败时直接返回去重后的候选而不做时间过滤;为了保证行为严格不变,重构后保留这一分支语义。
验证方式
- 新增单元测试覆盖
filterRecentRegularFiles(窗口内外、非常规文件、零值边界)与tempDirDeckFiles(目录名过滤、顶层 pptx); gofmt、go vet ./internal/httpapi/、go test ./internal/httpapi/相关用例通过。
- 主要語言
- Go
- 星號
- 141
- 分支
- 28
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 113
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Tencent/LoopForge 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
[Bug]: 官方镜像未安装 wecom-cli,企业微信通知报「通知服务未安装 wecom-cli」可能已有人在做 @newexploreor 於 1 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 76/100
Tencent/LoopForge#156 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
【架构优化】合并 gitwork/workbranch.go 中 push/pull 重复的默认提交身份注入为 withFallbackIdentity可能已有人在做 @fx-kurumi 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 40/100
維護者通常 1 天內回覆
-
【架构优化】从 runtime.installNPMCLI 中拆出 npm 参数拼装 npmCLIInstallArgs 与安装结果启用 activateNPMStage可能已有人在做 @fx-kurumi 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 30/100
維護者通常 1 天內回覆
查看 Tencent/LoopForge 的全部 Issue
相似的 Issue
-
team:library-maintainers
難度 2/5 1-3 小時 新手友好度 82/100
padok-team/burrito#1208 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
bazel-contrib/rules_go#4784 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 62/100
POSIdev-community/aictl#40 ·
-
難度 1/5 1 小時以內 新手友好度 62/100
prime-radiant-inc/evener#6306 ·
維護者通常 1 天內回覆