@@ -152,7 +152,7 @@ namespace mamba
152
152
cb.value ()(success.transfer .downloaded_size );
153
153
}
154
154
m_needs_download = false ;
155
- m_downloaded_url = success. transfer . effective_url ;
155
+ m_downloaded_url = m_package_info. package_url ;
156
156
return expected_t <void >();
157
157
};
158
158
@@ -317,53 +317,43 @@ namespace mamba
317
317
/* ******************
318
318
* Private methods *
319
319
*******************/
320
- // TODO to be removed if not used
321
- bool PackageFetcher::is_local_package () const
322
- {
323
- return util::starts_with (m_package_info.package_url , " file://" );
324
- }
325
320
326
- bool PackageFetcher::use_explicit_https_url () const
321
+ const std::string& PackageFetcher::filename () const
327
322
{
328
- // This excludes OCI case, which uses explicitly a "oci://" scheme,
329
- // but is resolved later to something starting with `oci_base_url`
330
- constexpr std::string_view oci_base_url = " https://pkg-containers.githubusercontent.com/" ;
331
- return util::starts_with (m_package_info.package_url , " https://" )
332
- && !util::starts_with (m_package_info.package_url , oci_base_url);
323
+ return m_package_info.filename ;
333
324
}
334
325
335
- const std::string& PackageFetcher::filename () const
326
+ bool PackageFetcher::use_oci () const
336
327
{
337
- return m_package_info.filename ;
328
+ constexpr std::string_view oci_scheme = " oci://" ;
329
+ return util::starts_with (m_package_info.package_url , oci_scheme);
338
330
}
339
331
332
+ // NOTE
333
+ // In the general case (not fetching from an oci registry),
334
+ // `channel()` and `url_path()` are concatenated when passed to `HTTPMirror`
335
+ // and the channel is resolved if needed (using the channel alias).
336
+ // Therefore, `util::url_concat("", m_package_info.package_url)`
337
+ // and `util::url_concat(m_package_info.channel, m_package_info.platform,
338
+ // m_package_info.filename)` should be equivalent, except when an explicit url is used as a spec
339
+ // with `--override-channels` option.
340
+ // Hence, we are favoring the first option (returning "" and `m_package_info.package_url`
341
+ // to be concatenated), valid for all the mentioned cases used with `HTTPMirror`.
342
+ // In the case of fetching from oci registries (using `OCIMirror`),the actual url
343
+ // used is built differently, and returning `m_package_info.package_url` is not relevant
344
+ // (i.e oci://ghcr.io/<mirror>/<channel>/<platform>/<filename>).
340
345
std::string PackageFetcher::channel () const
341
346
{
342
- // if (is_local_package() || use_explicit_https_url())
343
- // {
344
- // // Use explicit url or local package path
345
- // // to fetch package, leaving the channel empty.
346
- // return "";
347
- // }
348
- // return m_package_info.channel;
349
- if (util::starts_with (m_package_info.package_url , " oci://" ))
347
+ if (use_oci ())
350
348
{
351
349
return m_package_info.channel ;
352
350
}
353
351
return " " ;
354
352
}
355
353
356
- // TODO to rename, second_part_url?
357
354
std::string PackageFetcher::url_path () const
358
355
{
359
- // if (is_local_package() || use_explicit_https_url())
360
- // {
361
- // // Use explicit url or local package path
362
- // // to fetch package.
363
- // return m_package_info.package_url;
364
- // }
365
- // return util::concat(m_package_info.platform, '/', m_package_info.filename);
366
- if (util::starts_with (m_package_info.package_url , " oci://" ))
356
+ if (use_oci ())
367
357
{
368
358
return util::concat (m_package_info.platform , ' /' , m_package_info.filename );
369
359
}
0 commit comments