#!/usr/bin/env bash
# Offline integrity check: every model blob's SHA-256 must equal its file name,
# and the bundled installer archive / VSIX must match their recorded checksums.
. "$(dirname "$0")/common.sh"

fail=0
for f in "$OLLAMA_MODELS"/blobs/sha256-*; do
  want=${f##*/sha256-}
  got=$(sha256sum "$f" | cut -d' ' -f1)
  if [[ $got == "$want" ]]; then echo "OK   ${f##*/}"; else echo "BAD  ${f##*/}"; fail=1; fi
done
if [[ -d $BASE/downloads ]]; then
  (cd "$BASE/downloads" && grep ' ./ollama-linux-amd64.tar.zst$' sha256sum.txt | sha256sum -c - && sha256sum -c continue-win32-x64-2.0.0.vsix.sha256) || fail=1
fi
exit $fail
