Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 906adadacd2d
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 42f0246698cf
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Apr 9, 2021

  1. Revert "libfetchers/tarball: Lock on effectiveUrl"

    This reverts commit fc6bfb2.
    
    Fixes #4672.
    edolstra committed Apr 9, 2021
    Copy the full SHA
    42f0246 View commit details
Showing with 9 additions and 24 deletions.
  1. +1 −7 src/libfetchers/fetchers.hh
  2. +3 −3 src/libfetchers/github.cc
  3. +5 −14 src/libfetchers/tarball.cc
8 changes: 1 addition & 7 deletions src/libfetchers/fetchers.hh
Original file line number Diff line number Diff line change
@@ -145,13 +145,7 @@ DownloadFileResult downloadFile(
bool immutable,
const Headers & headers = {});

struct DownloadTarballMeta
{
time_t lastModified;
std::string effectiveUrl;
};

std::pair<Tree, DownloadTarballMeta> downloadTarball(
std::pair<Tree, time_t> downloadTarball(
ref<Store> store,
const std::string & url,
const std::string & name,
6 changes: 3 additions & 3 deletions src/libfetchers/github.cc
Original file line number Diff line number Diff line change
@@ -207,16 +207,16 @@ struct GitArchiveInputScheme : InputScheme

auto url = getDownloadUrl(input);

auto [tree, meta] = downloadTarball(store, url.url, "source", true, url.headers);
auto [tree, lastModified] = downloadTarball(store, url.url, "source", true, url.headers);

input.attrs.insert_or_assign("lastModified", uint64_t(meta.lastModified));
input.attrs.insert_or_assign("lastModified", uint64_t(lastModified));

getCache()->add(
store,
immutableAttrs,
{
{"rev", rev->gitRev()},
{"lastModified", uint64_t(meta.lastModified)}
{"lastModified", uint64_t(lastModified)}
},
tree.storePath,
true);
19 changes: 5 additions & 14 deletions src/libfetchers/tarball.cc
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ DownloadFileResult downloadFile(
};
}

std::pair<Tree, DownloadTarballMeta> downloadTarball(
std::pair<Tree, time_t> downloadTarball(
ref<Store> store,
const std::string & url,
const std::string & name,
@@ -127,10 +127,7 @@ std::pair<Tree, DownloadTarballMeta> downloadTarball(
if (cached && !cached->expired)
return {
Tree(store->toRealPath(cached->storePath), std::move(cached->storePath)),
{
.lastModified = time_t(getIntAttr(cached->infoAttrs, "lastModified")),
.effectiveUrl = maybeGetStrAttr(cached->infoAttrs, "effectiveUrl").value_or(url),
},
getIntAttr(cached->infoAttrs, "lastModified")
};

auto res = downloadFile(store, url, name, immutable, headers);
@@ -155,7 +152,6 @@ std::pair<Tree, DownloadTarballMeta> downloadTarball(

Attrs infoAttrs({
{"lastModified", uint64_t(lastModified)},
{"effectiveUrl", res.effectiveUrl},
{"etag", res.etag},
});

@@ -168,10 +164,7 @@ std::pair<Tree, DownloadTarballMeta> downloadTarball(

return {
Tree(store->toRealPath(*unpackedStorePath), std::move(*unpackedStorePath)),
{
.lastModified = lastModified,
.effectiveUrl = res.effectiveUrl,
},
lastModified,
};
}

@@ -230,11 +223,9 @@ struct TarballInputScheme : InputScheme
return true;
}

std::pair<Tree, Input> fetch(ref<Store> store, const Input & _input) override
std::pair<Tree, Input> fetch(ref<Store> store, const Input & input) override
{
Input input(_input);
auto [tree, meta] = downloadTarball(store, getStrAttr(input.attrs, "url"), "source", false);
input.attrs.insert_or_assign("url", meta.effectiveUrl);
auto tree = downloadTarball(store, getStrAttr(input.attrs, "url"), "source", false).first;
return {std::move(tree), input};
}
};