diff options
Diffstat (limited to 'src/libfetchers/tarball.cc')
-rw-r--r-- | src/libfetchers/tarball.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index f467a3c49..eb2422dac 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -115,7 +115,7 @@ DownloadFileResult downloadFile( }; } -std::pair<Tree, time_t> downloadTarball( +std::pair<Tree, DownloadTarballMeta> downloadTarball( ref<Store> store, const std::string & url, const std::string & name, @@ -133,7 +133,10 @@ std::pair<Tree, time_t> downloadTarball( if (cached && !cached->expired) return { Tree(store->toRealPath(cached->storePath), std::move(cached->storePath)), - getIntAttr(cached->infoAttrs, "lastModified") + { + .lastModified = time_t(getIntAttr(cached->infoAttrs, "lastModified")), + .effectiveUrl = maybeGetStrAttr(cached->infoAttrs, "effectiveUrl").value_or(url), + }, }; auto res = downloadFile(store, url, name, immutable, headers); @@ -158,6 +161,7 @@ std::pair<Tree, time_t> downloadTarball( Attrs infoAttrs({ {"lastModified", uint64_t(lastModified)}, + {"effectiveUrl", res.effectiveUrl}, {"etag", res.etag}, }); @@ -170,7 +174,10 @@ std::pair<Tree, time_t> downloadTarball( return { Tree(store->toRealPath(*unpackedStorePath), std::move(*unpackedStorePath)), - lastModified, + { + .lastModified = lastModified, + .effectiveUrl = res.effectiveUrl, + }, }; } @@ -229,9 +236,11 @@ 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 { - auto tree = downloadTarball(store, getStrAttr(input.attrs, "url"), "source", false).first; + Input input(_input); + auto [tree, meta] = downloadTarball(store, getStrAttr(input.attrs, "url"), "source", false); + input.attrs.insert_or_assign("url", meta.effectiveUrl); return {std::move(tree), input}; } }; |