fserrors: fix out of space detection on Windows - fixes #8011
IsErrNoSpace compared against syscall.ENOSPC. Go defines that constant on Windows as a value in its application reserved range which no Windows API returns, so the comparison could never be true there. A full disk on Windows reports ERROR_DISK_FULL or ERROR_HANDLE_DISK_FULL instead. Preallocation failures were still caught, because those return a separate sentinel, but a disk that is already full fails at the directory creation or at the open long before preallocation is reached. That is the case reported. The errors are now held in a list which platform specific files add to in their init, which is the shape retriable_errors already uses in this package, and the comparison itself is unchanged. Windows appends the two codes that lib/file already recognises when preallocation fails. Every other platform keeps exactly the behaviour it had. This also reaches the VFS cache, which uses the same helper and has no preallocation path of its own, so its out of space handling has been inert on Windows.
This commit is contained in:
committed by
Nick Craig-Wood
parent
c875d89033
commit
ca41db095b
@@ -0,0 +1,37 @@
|
||||
//go:build windows
|
||||
|
||||
package local
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/rclone/rclone/fs/fserrors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func TestUpdateFatalIfNoSpaceWindows(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
err error
|
||||
}{
|
||||
{"ERROR_DISK_FULL", windows.ERROR_DISK_FULL},
|
||||
{"openat PathError", &os.PathError{Op: "openat", Path: "test.txt", Err: windows.ERROR_DISK_FULL}},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Run("off", func(t *testing.T) {
|
||||
err := updateWithReader(t, false, test.err)
|
||||
require.Error(t, err)
|
||||
assert.False(t, fserrors.IsFatalError(err))
|
||||
})
|
||||
t.Run("on", func(t *testing.T) {
|
||||
err := updateWithReader(t, true, test.err)
|
||||
require.Error(t, err)
|
||||
assert.True(t, fserrors.IsFatalError(err))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user