@@ -109,7 +109,7 @@ DownloadFileResult downloadFile(
109109 };
110110}
111111
112- std::pair<Tree, time_t > downloadTarball (
112+ std::pair<Tree, DownloadTarballMeta > downloadTarball (
113113 ref<Store> store,
114114 const std::string & url,
115115 const std::string & name,
@@ -127,7 +127,10 @@ std::pair<Tree, time_t> downloadTarball(
127127 if (cached && !cached->expired )
128128 return {
129129 Tree (store->toRealPath (cached->storePath ), std::move (cached->storePath )),
130- getIntAttr (cached->infoAttrs , " lastModified" )
130+ {
131+ .lastModified = time_t (getIntAttr (cached->infoAttrs , " lastModified" )),
132+ .effectiveUrl = maybeGetStrAttr (cached->infoAttrs , " effectiveUrl" ).value_or (url),
133+ },
131134 };
132135
133136 auto res = downloadFile (store, url, name, immutable, headers);
@@ -152,6 +155,7 @@ std::pair<Tree, time_t> downloadTarball(
152155
153156 Attrs infoAttrs ({
154157 {" lastModified" , uint64_t (lastModified)},
158+ {" effectiveUrl" , res.effectiveUrl },
155159 {" etag" , res.etag },
156160 });
157161
@@ -164,7 +168,10 @@ std::pair<Tree, time_t> downloadTarball(
164168
165169 return {
166170 Tree (store->toRealPath (*unpackedStorePath), std::move (*unpackedStorePath)),
167- lastModified,
171+ {
172+ .lastModified = lastModified,
173+ .effectiveUrl = res.effectiveUrl ,
174+ },
168175 };
169176}
170177
@@ -223,9 +230,11 @@ struct TarballInputScheme : InputScheme
223230 return true ;
224231 }
225232
226- std::pair<Tree, Input> fetch (ref<Store> store, const Input & input ) override
233+ std::pair<Tree, Input> fetch (ref<Store> store, const Input & _input ) override
227234 {
228- auto tree = downloadTarball (store, getStrAttr (input.attrs , " url" ), " source" , false ).first ;
235+ Input input (_input);
236+ auto [tree, meta] = downloadTarball (store, getStrAttr (input.attrs , " url" ), " source" , false );
237+ input.attrs .insert_or_assign (" url" , meta.effectiveUrl );
229238 return {std::move (tree), input};
230239 }
231240};
0 commit comments