-
Notifications
You must be signed in to change notification settings - Fork 376
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
Split the transaction.hpp header #2564
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright (c) 2023, QuantStack and Mamba Contributors | ||
// | ||
// Distributed under the terms of the BSD 3-Clause License. | ||
// | ||
// The full license is in the file LICENSE, distributed with this software. | ||
|
||
|
||
#ifndef MAMBA_CORE_PACKAGE_DOWNLOAD_HPP | ||
#define MAMBA_CORE_PACKAGE_DOWNLOAD_HPP | ||
|
||
#include <future> | ||
#include <memory> | ||
#include <set> | ||
#include <string> | ||
#include <tuple> | ||
#include <vector> | ||
|
||
#include "fetch.hpp" | ||
#include "mamba_fs.hpp" | ||
#include "package_cache.hpp" | ||
#include "progress_bar.hpp" | ||
#include "thread_utils.hpp" | ||
|
||
namespace mamba | ||
{ | ||
class ChannelContext; | ||
|
||
class PackageDownloadExtractTarget | ||
{ | ||
public: | ||
|
||
enum VALIDATION_RESULT | ||
{ | ||
UNDEFINED = 0, | ||
VALID = 1, | ||
SHA256_ERROR, | ||
MD5SUM_ERROR, | ||
SIZE_ERROR, | ||
EXTRACT_ERROR | ||
}; | ||
|
||
PackageDownloadExtractTarget(const PackageInfo& pkg_info, ChannelContext& channel_context); | ||
|
||
void write_repodata_record(const fs::u8path& base_path); | ||
void add_url(); | ||
bool finalize_callback(const DownloadTarget& target); | ||
bool finished(); | ||
void validate(); | ||
bool extract(); | ||
bool extract_from_cache(); | ||
bool validate_extract(); | ||
const std::string& name() const; | ||
std::size_t expected_size() const; | ||
VALIDATION_RESULT validation_result() const; | ||
void clear_cache() const; | ||
|
||
DownloadTarget* target(MultiPackageCache& cache); | ||
|
||
std::exception m_decompress_exception; | ||
|
||
private: | ||
|
||
bool m_finished; | ||
PackageInfo m_package_info; | ||
|
||
std::string m_sha256, m_md5; | ||
std::size_t m_expected_size; | ||
|
||
bool m_has_progress_bars = false; | ||
ProgressProxy m_download_bar, m_extract_bar; | ||
std::unique_ptr<DownloadTarget> m_target; | ||
|
||
std::string m_url, m_name, m_filename; | ||
fs::u8path m_tarball_path, m_cache_path; | ||
|
||
std::future<bool> m_extract_future; | ||
|
||
VALIDATION_RESULT m_validation_result = VALIDATION_RESULT::UNDEFINED; | ||
|
||
std::function<void(ProgressBarRepr&)> extract_repr(); | ||
std::function<void(ProgressProxy&)> extract_progress_callback(); | ||
}; | ||
|
||
class DownloadExtractSemaphore | ||
{ | ||
public: | ||
|
||
static std::ptrdiff_t get_max(); | ||
static void set_max(int value); | ||
|
||
private: | ||
|
||
static counting_semaphore semaphore; | ||
|
||
friend class PackageDownloadExtractTarget; | ||
}; | ||
} // namespace mamba | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW do you know what this object is and why it's public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not yet worked with that code.
M guess is catching the exception is thread to rethrow in the main one.