forked from bkinnightskytw/code_work_spawner
資料夾被占用 #2
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
即便關閉程式,repo 資料夾仍有被占用的跡象,導致無法更名、刪除
分析:資料夾被占用的根本原因
問題來源(已驗證)
檢查程式碼後,找到兩個主要原因:
1.
disposeEphemeralWorkspace先開啟 GitDir 再刪除(scm_client.dart:69)Windows 上
git worktree remove執行過程中,workspacePath是該 git process 的 CWD,加上GitDir.fromExisting開啟的 handle,兩者在 Windows 上都會短暫佔用資料夾。2. Responder 子程序(及其孫程序)在 Windows 不會隨父程序一起結束(
cli_responder.dart:93-96)Windows 上,子程序不像 Unix 會繼承 process group;Dart runtime 也沒有建立 Windows Job Object 來綁定孫程序的生命週期。
流程:
workspacePath為 CWD 啟動(例如呼叫gh copilot/node等)workspacePathkill()──孫程序仍存活,繼續佔用該資料夾建議修法
短期(
scm_client.dart)──移除多餘的GitDir.fromExisting,並在 Windows 加入 retry長期(
cli_responder.dart)──不使用 workspace 作為 CWDResponder 已透過
CWS_WORKSPACE_PATH環境變數拿到路徑,因此可改用 project path(或系統暫存目錄)作為workingDirectory,避免孫程序繼承並持有 workspace CWD:摘要
GitDir.fromExisting在刪除前開啟 handlescm_client.dart:69git -C workspacePath的 CWD handle 釋放時序問題scm_client.dart:70-75cli_responder.dart:93-96Automation note: generated by
code_work_spawnerviagiteaas@MarioYang.