Tarball fetcher: Fix compat with old lock files that didn't include lastModified

Fixes flake-regressions/tests/DeterminateSystems/fh/0.1.10:

  error: fetching final input '{"final":true,"narHash":"sha256-0dZpggYjjmWEk+rGixiBHOHuQfLzEzNfrtjSig04s6Q=","rev":"9ccae1754eec0341b640d5705302ac0923d22875","revCount":1618,"type":"tarball","url":"https://api.flakehub.com/f/pinned/nix-community/fenix/0.1.1618%2Brev-9ccae1754eec0341b640d5705302ac0923d22875/018aea4c-03c9-7734-95d5-b84cc8881e3d/source.tar.gz"}' resulted in different input '{"final":true,"lastModified":1696141234,"narHash":"sha256-0dZpggYjjmWEk+rGixiBHOHuQfLzEzNfrtjSig04s6Q=","rev":"9ccae1754eec0341b640d5705302ac0923d22875","revCount":1618,"type":"tarball","url":"https://api.flakehub.com/f/pinned/nix-community/fenix/0.1.1618%2Brev-9ccae1754eec0341b640d5705302ac0923d22875/018aea4c-03c9-7734-95d5-b84cc8881e3d/source.tar.gz"}'
This commit is contained in:
Eelco Dolstra 2024-10-17 14:12:39 +02:00
parent ed1f9dd13f
commit 78b5b4c105

View File

@ -384,7 +384,11 @@ struct TarballInputScheme : CurlInputScheme
input = immutableInput;
}
if (result.lastModified && !input.attrs.contains("lastModified"))
/* If we got a lastModified and the input is not final and
doesn't have one, then return it. Note that we don't do
this if the input is final for compatibility with old lock
files that didn't include lastModified. */
if (result.lastModified && !_input.isFinal() && !input.attrs.contains("lastModified"))
input.attrs.insert_or_assign("lastModified", uint64_t(result.lastModified));
input.attrs.insert_or_assign("narHash",