Don't retry when "no space left on device" in local backend
Also adds relevant documentation to the restic.Backend interface.
This commit is contained in:
parent
e96677cafb
commit
f7784bddb3
4 changed files with 77 additions and 17 deletions
42
internal/backend/local/local_internal_test.go
Normal file
42
internal/backend/local/local_internal_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
)
|
||||
|
||||
func TestNoSpacePermanent(t *testing.T) {
|
||||
oldOpenFile := openFile
|
||||
defer func() {
|
||||
openFile = oldOpenFile
|
||||
}()
|
||||
|
||||
openFile = func(name string, flags int, mode os.FileMode) (*os.File, error) {
|
||||
// The actual error from os.OpenFile is *os.PathError.
|
||||
// Other functions called inside Save may return *os.SyscallError.
|
||||
return nil, os.NewSyscallError("open", syscall.ENOSPC)
|
||||
}
|
||||
|
||||
dir, cleanup := rtest.TempDir(t)
|
||||
defer cleanup()
|
||||
|
||||
be, err := Open(context.Background(), Config{Path: dir})
|
||||
rtest.OK(t, err)
|
||||
defer be.Close()
|
||||
|
||||
h := restic.Handle{Type: restic.ConfigFile}
|
||||
err = be.Save(context.Background(), h, nil)
|
||||
_, ok := err.(*backoff.PermanentError)
|
||||
rtest.Assert(t, ok,
|
||||
"error type should be backoff.PermanentError, got %T", err)
|
||||
rtest.Assert(t, errors.Is(err, syscall.ENOSPC),
|
||||
"could not recover original ENOSPC error")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue