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:
authorJames Fargher <jfargher@gitlab.com>2023-04-27 23:56:24 +0300
committerJames Fargher <jfargher@gitlab.com>2023-04-27 23:56:24 +0300
commit71e2b859209be127d7d4702198ff76fa7513e803 (patch)
tree8e2a87f3b0f5f70c94b15f11d43480f4f62d80b0
parentf3ec9d000bfcfcb5d3161b3eb9e379ba6138ed8a (diff)
backup: Use the localrepo.ErrEmptyBundle sentinel
This error indicates that git refused to create an empty bundle. This sentinel did not exist when backups were originally implemented. Now that it does we can simplify some of the error handling.
-rw-r--r--internal/backup/backup.go5
-rw-r--r--internal/backup/repository.go7
2 files changed, 3 insertions, 9 deletions
diff --git a/internal/backup/backup.go b/internal/backup/backup.go
index 12bc0f730..138e05578 100644
--- a/internal/backup/backup.go
+++ b/internal/backup/backup.go
@@ -26,9 +26,6 @@ var (
ErrDoesntExist = errors.New("doesn't exist")
)
-// errEmptyBundle means that the requested bundle contained nothing
-var errEmptyBundle = errors.New("empty bundle")
-
// Sink is an abstraction over the real storage used for storing/restoring backups.
type Sink interface {
// GetWriter saves the written data to relativePath. It is the callers
@@ -368,7 +365,7 @@ func (mgr *Manager) writeBundle(ctx context.Context, repo Repository, step *Step
}()
if err := repo.CreateBundle(ctx, w, io.MultiReader(negatedRefs, patternReader)); err != nil {
- if errors.Is(err, errEmptyBundle) {
+ if errors.Is(err, localrepo.ErrEmptyBundle) {
return fmt.Errorf("write bundle: %w: no changes to bundle", ErrSkipped)
}
return fmt.Errorf("write bundle: %w", err)
diff --git a/internal/backup/repository.go b/internal/backup/repository.go
index c21143d8c..5542864b9 100644
--- a/internal/backup/repository.go
+++ b/internal/backup/repository.go
@@ -136,7 +136,7 @@ func (rr *remoteRepository) CreateBundle(ctx context.Context, out io.Writer, pat
bundle := streamio.NewReader(func() ([]byte, error) {
resp, err := stream.Recv()
if structerr.GRPCCode(err) == codes.FailedPrecondition {
- err = errEmptyBundle
+ err = localrepo.ErrEmptyBundle
}
return resp.GetData(), err
})
@@ -223,10 +223,7 @@ func (r *localRepository) CreateBundle(ctx context.Context, out io.Writer, patte
err := r.repo.CreateBundle(ctx, out, &localrepo.CreateBundleOpts{
Patterns: patterns,
})
- switch {
- case errors.Is(err, localrepo.ErrEmptyBundle):
- return errEmptyBundle
- case err != nil:
+ if err != nil {
return fmt.Errorf("local repository: create bundle: %w", err)
}