OSDN Git Service

Update file.go (#584)
authorOuter-God <39217235+Outer-God@users.noreply.github.com>
Wed, 31 Mar 2021 11:19:54 +0000 (19:19 +0800)
committerGitHub <noreply@github.com>
Wed, 31 Mar 2021 11:19:54 +0000 (19:19 +0800)
* Update file.go

* Update file.go

* Update file.go

Co-authored-by: Welt <L5Accelerator@users.noreply.github.com>
toolbar/osssync/util/file.go

index 46a30f5..f5e3fb9 100644 (file)
@@ -1,6 +1,8 @@
 package util
 
-import "os"
+import (
+       "os"
+)
 
 // FileUtil is a struct of File utility
 type FileUtil struct {
@@ -18,11 +20,11 @@ func IsExists(path string) bool {
 
 // PathExists return if path exists
 func PathExists(path string) (bool, error) {
-       if _, err := os.Stat(path); err != nil {
-               return false, err
+       if _, err := os.Stat(path); os.IsNotExist(err) {
+               return false, nil
+       } else {
+               return err == nil, err
        }
-
-       return true, nil
 }
 
 // RemoveLocal deletes file