You've already forked agentic-coding-workflow
git workspace逻辑
This commit is contained in:
@@ -228,6 +228,21 @@ func (s *workspaceService) Sync(ctx context.Context, c Caller, wsID uuid.UUID) (
|
||||
}
|
||||
// 状态回写与请求生命周期解耦:客户端断开/请求超时也要能写回状态,避免永久卡 syncing。
|
||||
writeCtx := context.WithoutCancel(ctx)
|
||||
// main 仓库目录缺失(历史 clone 从未成功 / 数据卷丢失)时 fetch 注定失败,
|
||||
// 转为重新 clone 自愈:状态切回 cloning 并调度 CloneRunner,由其落 idle/error。
|
||||
if _, statErr := os.Stat(ws.MainPath); errors.Is(statErr, os.ErrNotExist) {
|
||||
if s.clones == nil {
|
||||
_, _ = s.repo.UpdateWorkspaceSyncStatus(writeCtx, wsID, SyncStatusError, ws.LastSyncedAt, "main repo missing on disk; clone scheduler unavailable")
|
||||
return nil, errs.New(errs.CodeGitCmdFailed, "main repo missing on disk")
|
||||
}
|
||||
updated, err := s.repo.UpdateWorkspaceSyncStatus(writeCtx, wsID, SyncStatusCloning, ws.LastSyncedAt, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.audit(writeCtx, &c.UserID, "workspace.reclone", "workspace", wsID.String(), map[string]any{"reason": "main path missing"})
|
||||
s.clones.Schedule(wsID)
|
||||
return updated, nil
|
||||
}
|
||||
fetchCtx, cancel := context.WithTimeout(ctx, s.fetchTimout)
|
||||
defer cancel()
|
||||
if fetchErr := s.gitr.Fetch(fetchCtx, ws.MainPath, cred); fetchErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user