Skip to content

Commit

Permalink
tests: Fix one multi-delete test failure in Windows CI (minio#9602)
Browse files Browse the repository at this point in the history
There is a disparency of behavior under Linux & Windows about
the returned error when trying to rename a non existant path.

err := os.Rename("/path/does/not/exist", "/tmp/copy")

Linux:
  isSysErrNotDir(err) = false
  os.IsNotExist(err) = true

Windows:
  isSysErrNotDir(err) = true
  os.IsNotExist(err) = true

ENOTDIR in Linux is returned when the destination path
of the rename call contains a file in one of the middle
segments of the path (e.g. /tmp/file/dst, where /tmp/file
is an actual file not a directory)

However, as shown above, Windows has more scenarios when
it returns ENOTDIR. For example, when the source path contains
an inexistant directory in its path.

In that case, we want errFileNotFound returned and not
errFileAccessDenied, so this commit will add a further check to close
the disparency between Windows & Linux.
  • Loading branch information
vadmeste authored May 15, 2020
1 parent 6c1bbf9 commit f44a960
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 5 additions & 1 deletion cmd/os-reliable.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ func renameAll(srcFilePath, dstFilePath string) (err error) {

if err = reliableRename(srcFilePath, dstFilePath); err != nil {
switch {
case isSysErrNotDir(err):
case isSysErrNotDir(err) && !os.IsNotExist(err):
// Windows can have both isSysErrNotDir(err) and os.IsNotExist(err) returning
// true if the source file path contains an inexistant directory. In that case,
// we want to return errFileNotFound instead, which will honored in subsequent
// switch cases
return errFileAccessDenied
case isSysErrPathNotFound(err):
// This is a special case should be handled only for
Expand Down
4 changes: 0 additions & 4 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"net/http"
"net/url"
"reflect"
"runtime"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -121,9 +120,6 @@ func runAllTests(suite *TestSuiteCommon, c *check) {
}

func TestServerSuite(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("cannot set up server reliably on Windows")
}
testCases := []*TestSuiteCommon{
// Init and run test on FS backend with signature v4.
{serverType: "FS", signer: signerV4},
Expand Down

0 comments on commit f44a960

Please sign in to comment.