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:
Diffstat (limited to 'internal/backup/locator.go')
-rw-r--r--internal/backup/locator.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/internal/backup/locator.go b/internal/backup/locator.go
index 1e1c42550..216037aea 100644
--- a/internal/backup/locator.go
+++ b/internal/backup/locator.go
@@ -294,17 +294,10 @@ func (l ManifestLocator) Commit(ctx context.Context, backup *Backup) (returnErr
return err
}
- f, err := l.Sink.GetWriter(ctx, manifestPath(backup.Repository, backup.ID))
- if err != nil {
+ if err := l.writeManifest(ctx, backup, backup.ID); err != nil {
return fmt.Errorf("manifest: commit: %w", err)
}
- defer func() {
- if err := f.Close(); err != nil && returnErr == nil {
- returnErr = fmt.Errorf("manifest: commit: %w", err)
- }
- }()
-
- if err := toml.NewEncoder(f).Encode(backup); err != nil {
+ if err := l.writeManifest(ctx, backup, "+latest"); err != nil {
return fmt.Errorf("manifest: commit: %w", err)
}
@@ -340,6 +333,24 @@ func (l ManifestLocator) Find(ctx context.Context, repo storage.Repository, back
return &backup, nil
}
+func (l ManifestLocator) writeManifest(ctx context.Context, backup *Backup, backupID string) (returnErr error) {
+ f, err := l.Sink.GetWriter(ctx, manifestPath(backup.Repository, backupID))
+ if err != nil {
+ return fmt.Errorf("write manifest: %w", err)
+ }
+ defer func() {
+ if err := f.Close(); err != nil && returnErr == nil {
+ returnErr = fmt.Errorf("write manifest: %w", err)
+ }
+ }()
+
+ if err := toml.NewEncoder(f).Encode(backup); err != nil {
+ return fmt.Errorf("write manifest: %w", err)
+ }
+
+ return nil
+}
+
func manifestPath(repo storage.Repository, backupID string) string {
storageName := repo.GetStorageName()
// Other locators strip the .git suffix off of relative paths. This suffix