From 42f0246698cff491f084547f7aaa9e778f629065 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 Apr 2021 13:51:57 +0200 Subject: [PATCH] Revert "libfetchers/tarball: Lock on effectiveUrl" This reverts commit fc6bfb261d50102016ed812ecf9949d41fe539f7. Fixes #4672. --- src/libfetchers/fetchers.hh | 8 +------- src/libfetchers/github.cc | 6 +++--- src/libfetchers/tarball.cc | 19 +++++-------------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/libfetchers/fetchers.hh b/src/libfetchers/fetchers.hh index c6b219c02..a72cfafa4 100644 --- a/src/libfetchers/fetchers.hh +++ b/src/libfetchers/fetchers.hh @@ -145,13 +145,7 @@ DownloadFileResult downloadFile( bool immutable, const Headers & headers = {}); -struct DownloadTarballMeta -{ - time_t lastModified; - std::string effectiveUrl; -}; - -std::pair downloadTarball( +std::pair downloadTarball( ref store, const std::string & url, const std::string & name, diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index 3e5ad75a8..8352ef02d 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -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); diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index bd05bb2f1..b8d7d2c70 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -109,7 +109,7 @@ DownloadFileResult downloadFile( }; } -std::pair downloadTarball( +std::pair downloadTarball( ref store, const std::string & url, const std::string & name, @@ -127,10 +127,7 @@ std::pair 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 downloadTarball( Attrs infoAttrs({ {"lastModified", uint64_t(lastModified)}, - {"effectiveUrl", res.effectiveUrl}, {"etag", res.etag}, }); @@ -168,10 +164,7 @@ std::pair 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 fetch(ref store, const Input & _input) override + std::pair fetch(ref 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}; } };