2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 22:27:35 +00:00

rewrite: start repository uploader goroutines

This commit is contained in:
Michael Eischer 2022-09-09 22:32:39 +02:00
parent 559acea0d8
commit 7ebaf6e899

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
"github.com/restic/restic/internal/backend" "github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/debug" "github.com/restic/restic/internal/debug"
@ -89,11 +90,22 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
return false return false
} }
filteredTree, err := walker.FilterTree(ctx, repo, "/", *sn.Tree, &walker.TreeFilterVisitor{ wg, wgCtx := errgroup.WithContext(ctx)
CheckExclude: checkExclude, repo.StartPackUploader(wgCtx, wg)
PrintExclude: func(path string) { Verbosef(fmt.Sprintf("excluding %s\n", path)) },
})
var filteredTree restic.ID
wg.Go(func() error {
filteredTree, err = walker.FilterTree(wgCtx, repo, "/", *sn.Tree, &walker.TreeFilterVisitor{
CheckExclude: checkExclude,
PrintExclude: func(path string) { Verbosef(fmt.Sprintf("excluding %s\n", path)) },
})
if err != nil {
return err
}
return repo.Flush(wgCtx)
})
err = wg.Wait()
if err != nil { if err != nil {
return false, err return false, err
} }
@ -109,11 +121,6 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
return true, nil return true, nil
} }
err = repo.Flush(ctx)
if err != nil {
return false, err
}
// Retain the original snapshot id over all tag changes. // Retain the original snapshot id over all tag changes.
if sn.Original == nil { if sn.Original == nil {
sn.Original = sn.ID() sn.Original = sn.ID()