input-output-hk / foliage

🌿 Foliage is a tool to create custom Haskell package repositories, in a fully reproducible way.
MIT License
42 stars 9 forks source link

The `RemoteAsset` rule should sanity check downloaded files where possible #77

Open michaelpj opened 1 year ago

michaelpj commented 1 year ago

It appears that downloading tarballs from GitHub can sometimes succeed but give you a truncated file (we've been observing this, and I can't see any other explanation). This is pretty bad, because it poisons the cache: we will just keep trying to unpack the tarball and fail, and nothing will change on a rerun.

The only sensible solutions I can think of are:

  1. Teach RemoteAsset that the target URI is, say, a .tar.gz file, and then test it before succeeding. In the case that I found, gunzip --test found the problem.
  2. Require specified hashes for all sources in the meta.toml. This will be pretty painful but we'd need it if we wanted Nix support anyway, so maybe we should just do it. See https://github.com/input-output-hk/foliage/issues/45

C.f. https://github.com/NixOS/nix/issues/4533 (we're using a new enough curl that the specific problem there shouldn't be happening, and I don't know why it is happening, but it definitely is happening)