【架构优化】从 RestoreMissingWorkspaceArtifacts 中拆出临时文件暂存逻辑 stageArchivedArtifact

オープン
#471 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@fx-kurumi がすでに取り組んでいます。

2026年11月13日 から。

  • #472 @fx-kurumi による — オープン

評価

難易度
2/5
見積もり時間
半日
初心者へのやさしさ
20/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
go
領域
backend

調査の方向性

Start in internal/runtime/workspace_artifacts.go at RestoreMissingWorkspaceArtifacts, and find the inline block that retries O_EXCL temp-file names, writes, chmods and cleans up on failure. The issue asks for that block to become stageArchivedArtifact with the same error text and permissions, and a new artifact_stage_test.go should cover the 0644 mode and the 10-collision failure. Note that linked PR #472 is already open against this issue, so check it before starting.

索引モデルが issue の本文から書いたものです。

説明

现状问题

internal/runtime/workspace_artifacts.go 中 RestoreMissingWorkspaceArtifacts 约 98 行,主循环里内嵌了一段约 30 行的「私有临时文件暂存」逻辑(最多 10 次 O_EXCL 抢名、写入、chmod 0644、Sync、Close、失败清理),和路径安全检查、Link 发布等逻辑混在一起,阅读和单测都不方便。

重构方案

  • 把暂存部分抽成包内函数 stageArchivedArtifact(base *os.Root, parent, content string) (string, error):返回临时文件的 root 相对路径;10 次抢名都失败时返回原错误 cannot stage archived artifact;写入失败会删掉残留的临时文件。
  • 主循环改为调用这个函数后 Link 发布,其余逻辑不动。

影响范围

只涉及 internal/runtime/workspace_artifacts.go(以及新增测试文件)。不改导出函数签名,行为、错误文字、文件权限都不变;调用方(runner/engine)不用改。

验证方式

  • gofmt、go vet ./internal/runtime/ ./internal/runner/
  • 现有 TestRestoreMissingArtifacts* 用例
  • 新增 artifact_stage_test.go:检查正常暂存(目录、内容、0644 权限)和连续 10 次重名后报错、之后能恢复
主要言語
Go
スター
141
フォーク
28
平均マージ
1日 15時間
マージ済み PR(30日)
113

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Tencent/LoopForge のほかの issue

Tencent/LoopForge の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。