Skip to content

Commit

Permalink
Tarball fetcher: Handle lock files that *do* contain lastModified
Browse files Browse the repository at this point in the history
Fixes flake-regressions/tests/DeterminateSystems/eva/0.1.0:

  error: 'lastModified' attribute mismatch in input 'https://api.flakehub.com/f/pinned/ipetkov/crane/0.14.1/018ac45c-ff5e-7076-b956-d478a0336516/source.tar.gz?narHash=sha256-mnE14re43v3/Jc50Jv0BKPMtEk7FEtDSligP6B5HwlI%3D', expected 1695511445
  • Loading branch information
edolstra committed Oct 17, 2024
1 parent 78b5b4c commit 7d1f7f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/libfetchers/fetchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ void InputScheme::checkLocks(const Input & specified, const Input & final) const

if (auto prevLastModified = specified.getLastModified()) {
if (final.getLastModified() != prevLastModified)
throw Error("'lastModified' attribute mismatch in input '%s', expected %d",
final.to_string(), *prevLastModified);
throw Error("'lastModified' attribute mismatch in input '%s', expected %d, got %d",
final.to_string(), *prevLastModified, final.getLastModified().value_or(-1));
}

if (auto prevRev = specified.getRev()) {
Expand Down
12 changes: 7 additions & 5 deletions src/libfetchers/tarball.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,13 @@ struct TarballInputScheme : CurlInputScheme
input = immutableInput;
}

/* 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"))
/* If we got a lastModified, then return it. But for
compatibility with old lock files that didn't include
lastModified, don't do this if the original input was final
and didn't contain a lastModified. */
if (result.lastModified
&& !input.attrs.contains("lastModified")
&& (!_input.isFinal() || _input.attrs.contains("lastModified")))
input.attrs.insert_or_assign("lastModified", uint64_t(result.lastModified));

input.attrs.insert_or_assign("narHash",
Expand Down

0 comments on commit 7d1f7f8

Please sign in to comment.