mirror of
https://github.com/restic/restic.git
synced 2025-03-09 00:00:02 +01:00
restic backup - handle MaxCapacityExceeded while saving a blob
If the capacity size limit condition is activated, a TreeBlob is passed through unharmed, so the new tree can be saved properly. A DataBlob however, which could be very large in size will be replaced by the data blob which contains the string "MaxCapacityExceeded\n".
This commit is contained in:
parent
bf227e6237
commit
612e21d42b
1 changed files with 14 additions and 0 deletions
|
@ -68,6 +68,16 @@ type saveBlobResponse struct {
|
|||
|
||||
func (s *blobSaver) saveBlob(ctx context.Context, t restic.BlobType, buf []byte) (saveBlobResponse, error) {
|
||||
id, known, sizeInRepo, err := s.repo.SaveBlob(ctx, t, buf, restic.ID{}, false)
|
||||
if err != nil && t == restic.TreeBlob && err.Error() == "MaxCapacityExceeded" {
|
||||
err = nil
|
||||
}
|
||||
|
||||
// need to modify data for repository monitoring being triggered
|
||||
if err != nil && t == restic.DataBlob && err.Error() == "MaxCapacityExceeded" {
|
||||
buf = []byte("MaxCapacityExceeded\n")
|
||||
id = restic.Hash(buf)
|
||||
return saveBlobResponse{id: id}, err
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return saveBlobResponse{}, err
|
||||
|
@ -95,6 +105,10 @@ func (s *blobSaver) worker(ctx context.Context, jobs <-chan saveBlobJob) error {
|
|||
}
|
||||
|
||||
res, err := s.saveBlob(ctx, job.BlobType, job.buf.Data)
|
||||
// pass through unharmed for repository monitoring
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue