aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/pkg.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-01-27 19:27:18 +0900
committerOphestra <cat@gensokyo.uk>2026-01-27 20:18:34 +0900
commit968d8dbaf14fa0e7965a8a525d74a2d8d6a20c50 (patch)
tree9ba3503fbc586eb504dfacfa3a471ff68a39b1e2 /internal/pkg/pkg.go
parentf1758a6fa8621777cb9129443b6de193c885228f (diff)
internal/pkg: encode checksum in ident
This also rearranges the ident ir to be more predictable, and avoids an obvious and somewhat easy to get into inconsistent state. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/pkg.go')
-rw-r--r--internal/pkg/pkg.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go
index 15114fd7..99772c8f 100644
--- a/internal/pkg/pkg.go
+++ b/internal/pkg/pkg.go
@@ -589,12 +589,21 @@ func (c *Cache) unsafeIdent(a Artifact, encodeKind bool) (
h := sha512.New384()
binary.LittleEndian.PutUint64(buf[:], uint64(a.Kind()))
h.Write(buf[:wordSize])
- i := IContext{c, h}
- a.Params(&i)
- i.cache, i.h = nil, nil
for _, dn := range idents {
h.Write(dn[:])
}
+ kcBuf := c.getIdentBuf()
+ if kc, ok := a.(KnownChecksum); ok {
+ *(*Checksum)(kcBuf[:]) = kc.Checksum()
+ } else {
+ *(*Checksum)(kcBuf[:]) = Checksum{}
+ }
+ h.Write((*Checksum)(kcBuf[:])[:])
+ c.putIdentBuf(kcBuf)
+
+ i := IContext{c, h}
+ a.Params(&i)
+ i.cache, i.h = nil, nil
h.Sum(buf[wordSize:wordSize])
return