Skip to content

Commit 610d301

Browse files
committed
Fix to ExistCheck method
1 parent 32a538b commit 610d301

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

paths.go

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"os"
3737
"path/filepath"
3838
"strings"
39+
"syscall"
3940
"time"
4041

4142
"github.com/pkg/errors"
@@ -274,6 +275,9 @@ func (p *Path) ExistCheck() (bool, error) {
274275
if os.IsNotExist(err) {
275276
return false, nil
276277
}
278+
if err.(*os.PathError).Err == syscall.ENOTDIR {
279+
return false, nil
280+
}
277281
return false, err
278282
}
279283

paths_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ func TestPath(t *testing.T) {
106106
require.False(t, anotherFilePath.IsNotDir())
107107
exist, err = anotherFilePath.ExistCheck()
108108
require.False(t, exist)
109-
require.Error(t, err)
109+
require.NoError(t, err)
110110
require.False(t, anotherFilePath.Exist())
111-
require.False(t, anotherFilePath.NotExist())
111+
require.True(t, anotherFilePath.NotExist())
112112

113113
list, err := folderPath.ReadDir()
114114
require.NoError(t, err)

0 commit comments

Comments
 (0)