Save files under temporary name in local backend

Fixes #3435.
This commit is contained in:
greatroar 2020-11-02 10:34:21 +01:00 committed by Michael Eischer
parent bc97a3d1f9
commit 195a5cf996
2 changed files with 35 additions and 26 deletions

View file

@ -3,6 +3,7 @@ package local
import (
"context"
"errors"
"fmt"
"os"
"syscall"
"testing"
@ -14,15 +15,13 @@ import (
)
func TestNoSpacePermanent(t *testing.T) {
oldOpenFile := openFile
oldTempFile := tempFile
defer func() {
openFile = oldOpenFile
tempFile = oldTempFile
}()
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)
tempFile = func(_, _ string) (*os.File, error) {
return nil, fmt.Errorf("not creating tempfile, %w", syscall.ENOSPC)
}
dir, cleanup := rtest.TempDir(t)