diff options
author | James Fargher <jfargher@gitlab.com> | 2023-10-26 05:01:53 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2023-11-08 23:37:40 +0300 |
commit | dae08e44427dae4d614e0bb59b7bef4e2062dc1d (patch) | |
tree | 30473e48ea561e8107bbdd878aff887bb6b76d34 | |
parent | d874d8c3eb0d0c9b9362b583ba8ccc42221140cd (diff) |
backup: Stop passing refs when writing a bundle
Refs are no longer needed in order to create a bundle file. So no need
to pass them through as a param.
This should open the door to streaming refs directly into the refs file
instead of keeping a slice in memory.
-rw-r--r-- | internal/backup/backup.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/internal/backup/backup.go b/internal/backup/backup.go index f339c659a..9f32ee22e 100644 --- a/internal/backup/backup.go +++ b/internal/backup/backup.go @@ -256,8 +256,10 @@ func (mgr *Manager) Create(ctx context.Context, req *CreateRequest) error { if err := mgr.writeRefs(ctx, step.RefPath, refs); err != nil { return fmt.Errorf("manager: %w", err) } - if err := mgr.writeBundle(ctx, repo, step, refs); err != nil { - return fmt.Errorf("manager: %w", err) + if len(refs) > 0 { + if err := mgr.writeBundle(ctx, repo, step); err != nil { + return fmt.Errorf("manager: %w", err) + } } if err := mgr.writeCustomHooks(ctx, repo, step.CustomHooksPath); err != nil { return fmt.Errorf("manager: %w", err) @@ -362,14 +364,10 @@ func setContextServerInfo(ctx context.Context, server *storage.ServerInfo, stora return nil } -func (mgr *Manager) writeBundle(ctx context.Context, repo Repository, step *Step, refs []git.Reference) (returnErr error) { - if len(refs) == 0 { - return nil - } - +func (mgr *Manager) writeBundle(ctx context.Context, repo Repository, step *Step) (returnErr error) { var patterns io.Reader - // Full backup, no need to check for known refs. if len(step.PreviousRefPath) > 0 { + // If there is a previous ref path, then we are creating an increment negatedRefs, err := mgr.negatedKnownRefs(ctx, step) if err != nil { return fmt.Errorf("write bundle: %w", err) |