Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 7d83bb9

Browse files
committed
gitserver: Clarify what RepositoryLock indicates
After refactoring to use the same locker for both tasks, this no longer only resembles cloneInProgress, so cleaned this up a little. Test plan: Existing test suites.
1 parent f04f859 commit 7d83bb9

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

cmd/gitserver/internal/repo_info.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ func repoCloneProgress(fs gitserverfs.FS, locker RepositoryLocker, repo api.Repo
2020
resp := protocol.RepoCloneProgress{
2121
Cloned: cloned,
2222
}
23-
resp.CloneProgress, resp.CloneInProgress = locker.Status(repo)
23+
cloneProgress, locked := locker.Status(repo)
2424
if isAlwaysCloningTest(repo) {
2525
resp.CloneInProgress = true
2626
resp.CloneProgress = "This will never finish cloning"
2727
}
28+
if !cloned && locked {
29+
resp.CloneInProgress = true
30+
resp.CloneProgress = cloneProgress
31+
}
2832
return &resp, nil
2933
}
3034

cmd/gitserver/internal/server_grpc.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,11 @@ func (gs *grpcServer) checkRepoExists(ctx context.Context, repo api.RepoName) er
14221422
}
14231423
}
14241424

1425-
cloneProgress, cloneInProgress := gs.locker.Status(repo)
1425+
cloneProgress, locked := gs.locker.Status(repo)
1426+
1427+
// We checked above that the repo is not cloned. So if the repo is currently
1428+
// locked, it must be a clone in progress.
1429+
cloneInProgress := locked
14261430

14271431
return newRepoNotFoundError(repo, cloneInProgress, cloneProgress)
14281432
}

cmd/gitserver/internal/serverutil.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
"github.com/sourcegraph/sourcegraph/internal/types"
1515
)
1616

17-
func cloneStatus(cloned, cloning bool) types.CloneStatus {
17+
func cloneStatus(cloned, locked bool) types.CloneStatus {
1818
switch {
1919
case cloned:
2020
return types.CloneStatusCloned
21-
case cloning:
21+
case locked:
2222
return types.CloneStatusCloning
2323
}
2424
return types.CloneStatusNotCloned

cmd/gitserver/internal/statesyncer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ func syncRepoState(
201201
// Failed to determine cloned state, we have to skip this record for now.
202202
continue
203203
}
204-
_, cloning := locker.Status(repo.Name)
204+
_, locked := locker.Status(repo.Name)
205205

206206
var shouldUpdate bool
207207
if repo.ShardID != shardID {
208208
repo.ShardID = shardID
209209
shouldUpdate = true
210210
}
211-
cloneStatus := cloneStatus(cloned, cloning)
211+
cloneStatus := cloneStatus(cloned, locked)
212212
if repo.CloneStatus != cloneStatus {
213213
repo.CloneStatus = cloneStatus
214214
// Since the repo has been recloned or is being cloned

0 commit comments

Comments
 (0)