|
karazeh
A cross-platform software updating library.
|
#include <downloader.hpp>
Inheritance diagram for kzh::downloader:
Collaboration diagram for kzh::downloader:Public Member Functions | |
| downloader (config_t const &, file_manager const &) | |
| virtual | ~downloader () |
| bool | fetch (string_t const &URI, string_t &out_buf) const |
| bool | fetch (string_t const &URI, std::ostream &out_file) const |
| bool | fetch (string_t const &URI, path_t const &path_to_file, string_t const &checksum, uint64_t expected_size_bytes=0, int *const nr_retries=NULL) const |
| int | retry_count () const |
| void | set_retry_count (int) |
Additional Inherited Members | |
Protected Member Functions inherited from kzh::logger | |
| void | rename_context (string_t const &) |
| logger (string_t context) | |
| virtual | ~logger () |
| logstream | alert () const |
| logstream | crit () const |
| logstream | debug () const |
| logstream | error () const |
| logstream | info () const |
| logstream | notice () const |
| logstream | plain () const |
| void | set_uuid_prefix (string_t const &) |
| string_t const & | uuid_prefix () const |
| logstream | warn () const |
Static Protected Member Functions inherited from kzh::logger | |
| static void | deindent () |
| static void | enable_timestamps (bool on_or_off) |
| static void | indent () |
| static void | mute () |
| static void | set_app_name (string_t const &app_name) |
| static void | set_stream (std::ostream *) |
| static void | set_threshold (char level) |
| static void | unmute () |
| kzh::downloader::downloader | ( | config_t const & | config, |
| file_manager const & | fmgr | ||
| ) |
|
virtual |
Downloads the file found at URI and stores it in out_buf. If does not start with http:// then it will be prefixed by the assigned server URI.
References kzh::download_t::buf, and kzh::download_t::uri.
Referenced by fetch(), kzh::version_manifest::load_from_uri(), kzh::version_manifest::load_release_from_uri(), kzh::on_curl_data(), kzh::update_operation::stage(), kzh::create_operation::stage(), and TEST_CASE().
| bool kzh::downloader::fetch | ( | string_t const & | URI, |
| std::ostream & | out_file | ||
| ) | const |
same as above but outputs to file instead of buffer
References fetch(), kzh::download_t::to_file, and kzh::download_t::uri.
| bool kzh::downloader::fetch | ( | string_t const & | URI, |
| path_t const & | path_to_file, | ||
| string_t const & | checksum, | ||
| uint64_t | expected_size_bytes = 0, |
||
| int *const | nr_retries = NULL |
||
| ) | const |
Downloads the file found at the given URI and verifies its integrity against the given checksum. The download will be retried up to retry_count() times.
Returns true if the file was downloaded and its integrity verified.
References kzh::hasher::digest_rc::digest, kzh::logger::error(), fetch(), kzh::KARAZEH_EXPORT::hasher, kzh::hasher::hex_digest(), kzh::file_manager::is_readable(), kzh::file_manager::load_file(), kzh::logger::notice(), kzh::download_t::retry_no, kzh::download_t::size, kzh::download_t::to_file, kzh::download_t::uri, kzh::KARAZEH_EXPORT::verbose, and kzh::logger::warn().
| int kzh::downloader::retry_count | ( | ) | const |
The number of times to retry a download
| void kzh::downloader::set_retry_count | ( | int | n | ) |
Referenced by TEST_CASE().