def sums.ok

ezx@1.11.0.0 · src/lock/world.bend:151

import ezx@1.11.0.0/src/lock/world.bend as World
import Base
import ezx@1.11.0.0/src/pkg/pkg.bend as K
import ezx@1.11.0.0/src/share/sha.bend as Sha

151# whether every text hashes to the sum its file is recorded with. A list of
152# texts that is longer or shorter than the files is not the package.
153def sums.ok(fs: List<&2, K.Item>, ss: List<&2, String>) -> Bool:
154  match fs ss:
155    case Nil{} Nil{}:
156      True{}
157    case Nil{} Con{_h, _t}:
158      False{}
159    case Con{_f, _g} Nil{}:
160      False{}
161    case Con{f, g} Con{s, t}:
162      +rest = sums.ok(g, t)
163      Bool.and(String.eq(Sha.hex(s), K.file.sum(f)), rest)

Uses (8)

Used by (1)