mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 06:46:34 +00:00
rewrite: start repository uploader goroutines
This commit is contained in:
parent
559acea0d8
commit
7ebaf6e899
@ -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)
|
||||||
|
repo.StartPackUploader(wgCtx, wg)
|
||||||
|
|
||||||
|
var filteredTree restic.ID
|
||||||
|
wg.Go(func() error {
|
||||||
|
filteredTree, err = walker.FilterTree(wgCtx, repo, "/", *sn.Tree, &walker.TreeFilterVisitor{
|
||||||
CheckExclude: checkExclude,
|
CheckExclude: checkExclude,
|
||||||
PrintExclude: func(path string) { Verbosef(fmt.Sprintf("excluding %s\n", path)) },
|
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user