Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/gitaly/service/repository/config.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/internal/gitaly/service/repository/config.go b/internal/gitaly/service/repository/config.go
index bfa69123e..452eabb82 100644
--- a/internal/gitaly/service/repository/config.go
+++ b/internal/gitaly/service/repository/config.go
@@ -192,19 +192,24 @@ func (s *server) voteOnConfig(ctx context.Context, repo *gitalypb.Repository) er
return fmt.Errorf("get repo path: %w", err)
}
- config, err := os.Open(filepath.Join(repoPath, "config"))
- if err != nil {
- return fmt.Errorf("open repo config: %w", err)
- }
+ var vote voting.Vote
- hash := voting.NewVoteHash()
- if _, err := io.Copy(hash, config); err != nil {
- return fmt.Errorf("seeding vote: %w", err)
- }
+ config, err := os.Open(filepath.Join(repoPath, "config"))
+ switch {
+ case err == nil:
+ hash := voting.NewVoteHash()
+ if _, err := io.Copy(hash, config); err != nil {
+ return fmt.Errorf("seeding vote: %w", err)
+ }
- vote, err := hash.Vote()
- if err != nil {
- return fmt.Errorf("computing vote: %w", err)
+ vote, err = hash.Vote()
+ if err != nil {
+ return fmt.Errorf("computing vote: %w", err)
+ }
+ case os.IsNotExist(err):
+ vote = voting.VoteFromData([]byte("notfound"))
+ default:
+ return fmt.Errorf("open repo config: %w", err)
}
if err := s.txManager.Vote(ctx, tx, vote); err != nil {