Revert "libfetchers/tarball: Lock on effectiveUrl"

This reverts commit fc6bfb261d.

Fixes #4672.
This commit is contained in:
Eelco Dolstra 2021-04-09 13:51:57 +02:00
parent 906adadacd
commit 42f0246698
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 9 additions and 24 deletions

View file

@ -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,

View file

@ -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);

View file

@ -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};
}
};