]> Cypherpunks.ru repositories - goredo.git/blobdiff - main.go
Fix another whichdo regression fix
[goredo.git] / main.go
diff --git a/main.go b/main.go
index d795544fe64a9b0a793aa724770380cb9e5d6ef0..504fa6c02beba2fa8f671a54833b0bb5bede8026 100644 (file)
--- a/main.go
+++ b/main.go
@@ -21,9 +21,11 @@ import (
        "bufio"
        "bytes"
        "encoding/hex"
+       "errors"
        "flag"
        "fmt"
        "io"
+       "io/fs"
        "log"
        "os"
        "os/signal"
@@ -198,7 +200,7 @@ func main() {
        LogLock = os.Getenv(EnvLogLock) == "1"
        LogJS = os.Getenv(EnvLogJS) == "1"
        if Debug || os.Getenv(EnvLogPid) == "1" {
-               MyPid = os.Getpid()
+               MyPID = os.Getpid()
        }
        var traced bool
        if flagTraceAll != nil && *flagTraceAll {
@@ -392,9 +394,13 @@ func main() {
                var dos []string
                dos, err = whichdo(tgts[0])
                if err != nil {
-                       break
+                       if errors.Is(err, fs.ErrNotExist) {
+                               err = nil
+                               ok = false
+                       } else {
+                               break
+                       }
                }
-               sort.Strings(dos)
                for _, do := range dos {
                        fmt.Println(do)
                }
@@ -507,7 +513,7 @@ func main() {
                DepFixHashCache = make(map[string]Hash)
                err = depFix(Cwd)
        case CmdNameRedoInode:
-               var inode Inode
+               var inode *Inode
                for _, tgt := range tgts {
                        inode, err = inodeFromFileByPath(tgt.a)
                        if err != nil {
@@ -542,6 +548,7 @@ func main() {
                }
                var typ byte
                var chunk []byte
+               var inode Inode
                for len(data) > 0 {
                        typ, chunk, data, _ = chunkRead(data)
                        switch typ {
@@ -561,7 +568,7 @@ func main() {
                                }...)
                        case DepTypeIfchange:
                                name := string(chunk[InodeLen+HashLen:])
-                               meta := string(chunk[:InodeLen+HashLen])
+                               meta := chunk[:InodeLen+HashLen]
                                fields := []recfile.Field{
                                        {Name: "Type", Value: "ifchange"},
                                        {Name: "Target", Value: name},
@@ -569,7 +576,8 @@ func main() {
                                fields = append(fields, recfile.Field{
                                        Name: "Hash", Value: Hash(meta[InodeLen:]).String(),
                                })
-                               fields = append(fields, Inode(meta[:InodeLen]).RecfileFields()...)
+                               inode = Inode(meta[:][:InodeLen])
+                               fields = append(fields, inode.RecfileFields()...)
                                err = recfileWrite(w, fields...)
                        case DepTypeIfchangeNonex:
                                err = recfileWrite(w, []recfile.Field{