]> Cypherpunks.ru repositories - goredo.git/blobdiff - ood.go
Do not use legacy os.IsNotExist
[goredo.git] / ood.go
diff --git a/ood.go b/ood.go
index 0c8d506b8ada12b827a8d7c7fba9dae028fbcb5a..1be39573bd4b15e2ad1ada84fec28210e9089337 100644 (file)
--- a/ood.go
+++ b/ood.go
@@ -23,10 +23,10 @@ import (
        "errors"
        "fmt"
        "io"
+       "io/fs"
        "log"
        "os"
        "path"
-       "path/filepath"
        "strings"
 
        "golang.org/x/sys/unix"
@@ -62,7 +62,7 @@ func FileExists(p string) bool {
                FileExistsCache[p] = true
                return true
        }
-       if os.IsNotExist(err) {
+       if errors.Is(err, fs.ErrNotExist) {
                FileExistsCache[p] = false
        }
        return false
@@ -79,23 +79,6 @@ func (e TgtError) Error() string {
        return fmt.Sprintf("%s: %s", e.Tgt, e.Err)
 }
 
-func cwdMustRel(paths ...string) string {
-       rel, err := filepath.Rel(Cwd, path.Join(paths...))
-       if err != nil {
-               panic(err)
-       }
-       return rel
-}
-
-func cwdAndTgt(tgt string) (string, string) {
-       cwd, tgt := path.Split(tgt)
-       cwd, err := filepath.Abs(cwd)
-       if err != nil {
-               panic(err)
-       }
-       return cwd, tgt
-}
-
 func isSrc(cwd, tgt string) bool {
        d, f := path.Split(path.Join(cwd, tgt))
        if !FileExists(path.Join(d, f)) {
@@ -194,7 +177,7 @@ func isOOD(cwd, tgtOrig string, level int, seen map[string]struct{}) (bool, erro
 
                inode, err := inodeFromFileByPath(path.Join(cwd, dep))
                if err != nil {
-                       if os.IsNotExist(err) {
+                       if errors.Is(err, fs.ErrNotExist) {
                                tracef(CDebug, "ood: %s%s -> %s: not exists", indent, tgtOrig, dep)
                                ood = true
                                OODCache[path.Join(cwd, dep)] = ood
@@ -270,11 +253,9 @@ func isOODWithTrace(
        level int,
        seen map[string]struct{},
 ) (bool, error) {
-       p, err := filepath.Abs(path.Join(cwd, tgtOrig))
-       if err != nil {
-               panic(err)
-       }
+       p := mustAbs(path.Join(cwd, tgtOrig))
        _, ood := OODTgts[p]
+       var err error
        if ood {
                if !isOODByBuildUUID(cwd, tgtOrig) {
                        tracef(