Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up fetch #2452

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions libmamba/include/mamba/core/fetch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,21 @@ namespace mamba
void set_expected_size(std::size_t size);
void set_head_only(bool yes);

const std::string& name() const;
const std::string& url() const;
std::size_t expected_size() const;
const std::string& get_name() const;
const std::string& get_url() const;

void init_curl_ssl();
void init_curl_target(const std::string& url);
const std::string& get_etag() const;
const std::string& get_mod() const;
const std::string& get_cache_control() const;

bool resource_exists();
bool perform();
CURL* handle();
std::size_t get_expected_size() const;
int get_http_status() const;
std::size_t get_downloaded_size() const;

curl_off_t get_speed();
std::size_t get_speed();

void init_curl_ssl();
void init_curl_target(const std::string& url);

template <class C>
inline void set_finalize_callback(bool (C::*cb)(const DownloadTarget&), C* data)
Expand All @@ -80,12 +83,18 @@ namespace mamba
m_ignore_failure = yes;
}

bool ignore_failure() const
bool get_ignore_failure() const
{
return m_ignore_failure;
}

void set_result(CURLcode r);
std::size_t get_result() const;

bool resource_exists();
bool perform();
CURL* handle();

bool finalize();
std::string get_transfer_msg();

Expand All @@ -95,16 +104,6 @@ namespace mamba
std::chrono::steady_clock::time_point progress_throttle_time() const;
void set_progress_throttle_time(const std::chrono::steady_clock::time_point& time);

CURLcode result = CURLE_OK;
bool failed = false;
int http_status = 10000;
char* effective_url = nullptr;
curl_off_t downloaded_size = 0;
curl_off_t avg_speed = 0;
std::string final_url;

std::string etag, mod, cache_control;

private:

std::unique_ptr<ZstdStream> m_zstd_stream;
Expand All @@ -114,16 +113,24 @@ namespace mamba

std::string m_name, m_filename, m_url;

int m_http_status;
std::size_t m_downloaded_size;
char* m_effective_url;

CURLcode m_result; // Enum range from 0 to 99

std::string m_etag, m_mod, m_cache_control;

// validation
std::size_t m_expected_size = 0;
std::size_t m_expected_size;

// retry & backoff
std::chrono::steady_clock::time_point m_next_retry;
std::size_t m_retry_wait_seconds = get_default_retry_timeout();
std::size_t m_retries = 0;
std::size_t m_retry_wait_seconds;
std::size_t m_retries;

bool m_has_progress_bar = false;
bool m_ignore_failure = false;
bool m_has_progress_bar;
bool m_ignore_failure;

ProgressProxy m_progress_bar;

Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/api/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ namespace mamba
tmp_lock_file = std::make_unique<TemporaryFile>();
DownloadTarget dt("Environment Lockfile", lockfile, tmp_lock_file->path());
bool success = dt.perform();
if (!success || dt.http_status != 200)
if (!success || dt.get_http_status() != 200)
{
throw std::runtime_error(
fmt::format("Could not download environment lockfile from {}", lockfile)
Expand Down
Loading