Skip to content

Commit 0a842c0

Browse files
author
奇淼(piexlmax
authored
Merge pull request flipped-aurora#895 from 4lkaid/4lkaid_main_develop
fix(utils/directory.go): 同名文件存在时正确返回
2 parents 400b2e0 + d9fa862 commit 0a842c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server/utils/directory.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package utils
22

33
import (
4+
"errors"
45
"os"
56

67
"github.com/flipped-aurora/gin-vue-admin/server/global"
@@ -14,9 +15,12 @@ import (
1415
//@return: bool, error
1516

1617
func PathExists(path string) (bool, error) {
17-
_, err := os.Stat(path)
18+
fi, err := os.Stat(path)
1819
if err == nil {
19-
return true, nil
20+
if fi.IsDir() {
21+
return true, nil
22+
}
23+
return false, errors.New("存在同名文件")
2024
}
2125
if os.IsNotExist(err) {
2226
return false, nil

0 commit comments

Comments
 (0)