]> Cypherpunks.ru repositories - goredo.git/blobdiff - depfix.go
Optimise memory storage of dependency information
[goredo.git] / depfix.go
index b045682f3c03cfe9c6013a6532cc65a1a68560b5..bf048798aad0a15c613deff75662ba3d54b9e193 100644 (file)
--- a/depfix.go
+++ b/depfix.go
@@ -18,6 +18,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 package main
 
 import (
+       "bytes"
+       "encoding/hex"
        "errors"
        "io"
        "io/fs"
@@ -110,7 +112,7 @@ func depFix(root string) error {
                                if err != nil {
                                        return ErrLine(err)
                                }
-                               theirHsh := m["Hash"]
+                               theirHsh := mustHexDecode(m["Hash"])
                                fd, err := os.Open(path.Join(root, dep))
                                if err != nil {
                                        if errors.Is(err, fs.ErrNotExist) {
@@ -148,7 +150,7 @@ func depFix(root string) error {
                                if err != nil {
                                        return ErrLine(err)
                                }
-                               if hsh != theirHsh {
+                               if !bytes.Equal(hsh, theirHsh) {
                                        tracef(
                                                CDebug, "depfix: %s/%s -> %s: hash differs",
                                                root, entry.Name(), dep,
@@ -158,7 +160,7 @@ func depFix(root string) error {
                                fields = []recfile.Field{
                                        {Name: "Type", Value: DepTypeIfchange},
                                        {Name: "Target", Value: dep},
-                                       {Name: "Hash", Value: hsh},
+                                       {Name: "Hash", Value: hex.EncodeToString(hsh)},
                                }
                                fields = append(fields, inode.RecfileFields()...)
                                fieldses[len(fieldses)-1] = fields