diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-04-05 18:29:52 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-04-05 18:29:52 -0400 |
commit | e12308dd63f0ad27b22dcdb3da89c411eebcad2b (patch) | |
tree | ce5a9b558ca9a2787e44614d7cd423f2d9318618 /src/libfetchers/tarball.cc | |
parent | f0ad29acc1f2c9e82679c3af434a8bf185f36b94 (diff) | |
parent | a07dc7e0d99d1cd91643c9ecc2b672399471eaf4 (diff) |
Merge branch 'master' into path-info
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}; } }; |