2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-26 20:30:19 +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"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/debug"
@ -89,11 +90,22 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
return false
}
filteredTree, err := walker.FilterTree(ctx, repo, "/", *sn.Tree, &walker.TreeFilterVisitor{
CheckExclude: checkExclude,
PrintExclude: func(path string) { Verbosef(fmt.Sprintf("excluding %s\n", path)) },
})
wg, wgCtx := errgroup.WithContext(ctx)
repo.StartPackUploader(wgCtx, wg)
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 {
return false, err
}
@ -109,11 +121,6 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
return true, nil
}
err = repo.Flush(ctx)
if err != nil {
return false, err
}
// Retain the original snapshot id over all tag changes.
if sn.Original == nil {
sn.Original = sn.ID()