mirror of
https://github.com/go-task/task.git
synced 2026-06-11 09:51:50 +00:00
fix(git): check cache before context timeout in getOrCloneRepo (#2669)
This commit is contained in:
@@ -128,19 +128,19 @@ func (node *GitNode) getOrCloneRepo(ctx context.Context) (string, error) {
|
||||
repoMutex.Lock()
|
||||
defer repoMutex.Unlock()
|
||||
|
||||
// Check if context was cancelled while waiting for lock
|
||||
if err := ctx.Err(); err != nil {
|
||||
return "", fmt.Errorf("context cancelled while waiting for repository lock: %w", err)
|
||||
}
|
||||
|
||||
cacheDir := filepath.Join(os.TempDir(), "task-git-repos", cacheKey)
|
||||
|
||||
// check if repo is already cached (under the lock)
|
||||
// Check cache FIRST - if already cloned, no network needed, timeout irrelevant
|
||||
gitDir := filepath.Join(cacheDir, ".git")
|
||||
if _, err := os.Stat(gitDir); err == nil {
|
||||
return cacheDir, nil
|
||||
}
|
||||
|
||||
// Only check context if we need to clone (requires network)
|
||||
if err := ctx.Err(); err != nil {
|
||||
return "", fmt.Errorf("context cancelled while waiting for repository lock: %w", err)
|
||||
}
|
||||
|
||||
getterURL := node.buildURL()
|
||||
|
||||
client := &getter.Client{
|
||||
|
||||
Reference in New Issue
Block a user