1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-03-09 00:00:02 +01:00

archiver in repository size monitoring mode

archiver.go: add repo parameter to newFileSaver(), remove unneeded check for monitoring check for saveTree

blob_saver.go: remove unneded monitoring check for worker()
This commit is contained in:
Winfried Plappert 2025-03-04 08:43:37 +00:00
parent 812bf976b9
commit 92fe006ee1
2 changed files with 12 additions and 16 deletions

View file

@ -156,6 +156,9 @@ type Options struct {
// SaveTreeConcurrency sets how many trees are marshalled and saved to the
// repo concurrently.
SaveTreeConcurrency uint
// RepoSizeMax > 0 signals repository size monitoring
RepoSizeMax uint64
}
// ApplyDefaults returns a copy of o with the default options set for all unset
@ -329,7 +332,6 @@ func (arch *Archiver) saveDir(ctx context.Context, snPath string, dir string, me
// test if context has been cancelled
if ctx.Err() != nil {
debug.Log("context has been cancelled, aborting")
return futureNode{}, ctx.Err()
}
@ -722,17 +724,14 @@ func (arch *Archiver) saveTree(ctx context.Context, snPath string, atree *tree,
return futureNode{}, 0, err
}
// don't descend into subdirectories if we are in shutdown mode
if !arch.Repo.MaxCapacityExceeded() {
// not a leaf node, archive subtree
fn, _, err := arch.saveTree(ctx, join(snPath, name), &subatree, oldSubtree, func(n *restic.Node, is ItemStats) {
arch.trackItem(snItem, oldNode, n, is, time.Since(start))
})
if err != nil {
return futureNode{}, 0, err
}
nodes = append(nodes, fn)
// not a leaf node, archive subtree
fn, _, err := arch.saveTree(ctx, join(snPath, name), &subatree, oldSubtree, func(n *restic.Node, is ItemStats) {
arch.trackItem(snItem, oldNode, n, is, time.Since(start))
})
if err != nil {
return futureNode{}, 0, err
}
nodes = append(nodes, fn)
}
fn := arch.treeSaver.Save(ctx, snPath, atree.FileInfoPath, node, nodes, complete)
@ -840,9 +839,10 @@ func (arch *Archiver) runWorkers(ctx context.Context, wg *errgroup.Group) {
arch.fileSaver = newFileSaver(ctx, wg,
arch.blobSaver.Save,
arch.Repo.Config().ChunkerPolynomial,
arch.Options.ReadConcurrency, arch.Options.SaveBlobConcurrency)
arch.Options.ReadConcurrency, arch.Options.SaveBlobConcurrency, arch.Repo)
arch.fileSaver.CompleteBlob = arch.CompleteBlob
arch.fileSaver.NodeFromFileInfo = arch.nodeFromFileInfo
//arch.fileSaver.repo = arch.Repo
arch.treeSaver = newTreeSaver(ctx, wg, arch.Options.SaveTreeConcurrency, arch.blobSaver.Save, arch.Error)
}

View file

@ -3,7 +3,6 @@ package archiver
import (
"context"
"fmt"
//"sync"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/restic"
@ -97,9 +96,6 @@ func (s *blobSaver) worker(ctx context.Context, jobs <-chan saveBlobJob) error {
}
res, err := s.saveBlob(ctx, job.BlobType, job.buf.Data)
if err != nil && err.Error() == "MaxCapacityExceeded" {
err = nil
}
if err != nil {
debug.Log("saveBlob returned error, exiting: %v", err)
return fmt.Errorf("failed to save blob from file %q: %w", job.fn, err)