Skip to content

Commit 07bf5bd

Browse files
Merge pull request #131 from ibuildthecloud/distribution
Lock tool during repo setup
2 parents 4909c51 + f282175 commit 07bf5bd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/repos/get.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"path/filepath"
1111

12+
"github.com/BurntSushi/locker"
1213
"github.com/gptscript-ai/gptscript/pkg/repos/git"
1314
"github.com/gptscript-ai/gptscript/pkg/types"
1415
)
@@ -52,6 +53,9 @@ func New(cacheDir string, runtimes ...Runtime) *Manager {
5253
}
5354

5455
func (m *Manager) setup(ctx context.Context, runtime Runtime, tool types.Tool, env []string) (string, []string, error) {
56+
locker.Lock(tool.ID)
57+
defer locker.Unlock(tool.ID)
58+
5559
target := filepath.Join(m.storageDir, tool.Source.Repo.Revision, runtime.ID())
5660
targetFinal := filepath.Join(target, tool.Source.Repo.Path)
5761
doneFile := target + ".done"

pkg/repos/git/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func cloneBare(ctx context.Context, repo, toDir string) error {
1919
}
2020

2121
func gitWorktreeAdd(ctx context.Context, gitDir, commitDir, commit string) error {
22-
cmd := newGitCommand(ctx, "--git-dir", gitDir, "worktree", "add", "-f", commitDir, commit)
22+
// The double -f is intentional
23+
cmd := newGitCommand(ctx, "--git-dir", gitDir, "worktree", "add", "-f", "-f", commitDir, commit)
2324
return cmd.Run()
2425
}
2526

0 commit comments

Comments
 (0)