fix(utils/directory.go): 同名文件存在时正确返回
This commit is contained in:
parent
6dbcd55727
commit
e8d0b39b5d
|
@ -1,6 +1,7 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||||
|
@ -14,10 +15,13 @@ import (
|
||||||
//@return: bool, error
|
//@return: bool, error
|
||||||
|
|
||||||
func PathExists(path string) (bool, error) {
|
func PathExists(path string) (bool, error) {
|
||||||
_, err := os.Stat(path)
|
fi, err := os.Stat(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if fi.IsDir() {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
return false, errors.New("存在同名文件")
|
||||||
|
}
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue