mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:12:02 +00:00
gitserver: Clarify what RepositoryLock indicates (#61862)
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.
This commit is contained in:
parent
f04f859ba8
commit
a2b170dc9e
@ -20,11 +20,15 @@ func repoCloneProgress(fs gitserverfs.FS, locker RepositoryLocker, repo api.Repo
|
||||
resp := protocol.RepoCloneProgress{
|
||||
Cloned: cloned,
|
||||
}
|
||||
resp.CloneProgress, resp.CloneInProgress = locker.Status(repo)
|
||||
cloneProgress, locked := locker.Status(repo)
|
||||
if isAlwaysCloningTest(repo) {
|
||||
resp.CloneInProgress = true
|
||||
resp.CloneProgress = "This will never finish cloning"
|
||||
}
|
||||
if !cloned && locked {
|
||||
resp.CloneInProgress = true
|
||||
resp.CloneProgress = cloneProgress
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
|
||||
@ -1422,7 +1422,11 @@ func (gs *grpcServer) checkRepoExists(ctx context.Context, repo api.RepoName) er
|
||||
}
|
||||
}
|
||||
|
||||
cloneProgress, cloneInProgress := gs.locker.Status(repo)
|
||||
cloneProgress, locked := gs.locker.Status(repo)
|
||||
|
||||
// We checked above that the repo is not cloned. So if the repo is currently
|
||||
// locked, it must be a clone in progress.
|
||||
cloneInProgress := locked
|
||||
|
||||
return newRepoNotFoundError(repo, cloneInProgress, cloneProgress)
|
||||
}
|
||||
|
||||
@ -14,11 +14,11 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/types"
|
||||
)
|
||||
|
||||
func cloneStatus(cloned, cloning bool) types.CloneStatus {
|
||||
func cloneStatus(cloned, locked bool) types.CloneStatus {
|
||||
switch {
|
||||
case cloned:
|
||||
return types.CloneStatusCloned
|
||||
case cloning:
|
||||
case locked:
|
||||
return types.CloneStatusCloning
|
||||
}
|
||||
return types.CloneStatusNotCloned
|
||||
|
||||
@ -201,14 +201,14 @@ func syncRepoState(
|
||||
// Failed to determine cloned state, we have to skip this record for now.
|
||||
continue
|
||||
}
|
||||
_, cloning := locker.Status(repo.Name)
|
||||
_, locked := locker.Status(repo.Name)
|
||||
|
||||
var shouldUpdate bool
|
||||
if repo.ShardID != shardID {
|
||||
repo.ShardID = shardID
|
||||
shouldUpdate = true
|
||||
}
|
||||
cloneStatus := cloneStatus(cloned, cloning)
|
||||
cloneStatus := cloneStatus(cloned, locked)
|
||||
if repo.CloneStatus != cloneStatus {
|
||||
repo.CloneStatus = cloneStatus
|
||||
// Since the repo has been recloned or is being cloned
|
||||
|
||||
Loading…
Reference in New Issue
Block a user