diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-04-05 19:06:30 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-04-05 19:06:30 -0400 |
commit | cdc9f34a44aacbc8dbfa232a7620531a689d9c43 (patch) | |
tree | 11984c860dbc5c64bb2443737167f5ed4c1d1595 /src/libfetchers/tarball.cc | |
parent | 7863036634ccb07e1933cd0b106fc27d5c073004 (diff) | |
parent | e12308dd63f0ad27b22dcdb3da89c411eebcad2b (diff) |
Merge commit 'e12308dd63f0ad27b22dcdb3da89c411eebcad2b' into ca-drv-exotic
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}; } }; |