karazeh
A cross-platform software updating library.
kzh::create_operation Class Reference

#include <create.hpp>

+ Inheritance diagram for kzh::create_operation:
+ Collaboration diagram for kzh::create_operation:

Public Member Functions

 create_operation (config_t const &, release_manifest const &)
 
virtual ~create_operation ()
 
virtual void commit ()
 
virtual STAGE_RC deploy ()
 
void marked_for_deletion ()
 
virtual void rollback ()
 
virtual STAGE_RC stage ()
 
virtual string_t tostring ()
 
- Public Member Functions inherited from kzh::operation
 operation (config_t const &config, release_manifest const &rm)
 
virtual ~operation ()
 

Public Attributes

string_t dst_path
 
bool is_executable
 
string_t src_checksum
 
uint64_t src_size
 
string_t src_uri
 

Protected Member Functions

path_t get_destination () const
 
bool has_deployed () const
 
- 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
 

Additional Inherited Members

- 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 ()
 
- Protected Attributes inherited from kzh::operation
config_t const & config_
 
release_manifest const & rm_
 

Constructor & Destructor Documentation

kzh::create_operation::create_operation ( config_t const &  config,
release_manifest const &  rm 
)
kzh::create_operation::~create_operation ( )
virtual

Member Function Documentation

void kzh::create_operation::commit ( )
virtual

Purging is handy for operations that use the Karazeh cache while deploying or staging. When an operation is called to commit, it is guaranteed that the patch has been rolled out successfully and any transient data will not be needed (no rollback will be invoked).

The cache is used for operations that require storing some data in a safe place only for the use of rollbacks if required, but should otherwise be discarded.

Reimplemented from kzh::operation.

References kzh::operation::config_, kzh::file_manager::exists(), kzh::KARAZEH_EXPORT::file_manager, kzh::KARAZEH_EXPORT::hasher, kzh::hasher::hex_digest(), kzh::file_manager::remove_file(), and src_checksum.

Referenced by TEST_CASE().

STAGE_RC kzh::create_operation::deploy ( )
virtual
path_t kzh::create_operation::get_destination ( ) const
protected
void kzh::create_operation::marked_for_deletion ( )
void kzh::create_operation::rollback ( )
virtual

Rolling-back ALL the changes that have been made to the repository while stage()ing or deploy()ing.

Use internal flags or members to keep track of the changes you make if necessary. rollback() might be invoked after operation::stage(), operation::deploy(), or neither!

Implements kzh::operation.

References kzh::operation::config_, kzh::KARAZEH_EXPORT::file_manager, get_destination(), has_deployed(), kzh::file_manager::is_empty(), kzh::file_manager::move(), and kzh::file_manager::remove_directory().

Referenced by TEST_CASE().

STAGE_RC kzh::create_operation::stage ( )
virtual

Downloads the file from src_uri and stores it in the staging temporary repository. If an integrity mismatch occurs, the file will be re-downloaded up to resource_manager::download_retries times.

The following conditions must be met for the staging to be successful:

  1. No file must exist at dst_path
  2. Running user must have write permissions for dst_path
  3. Enough available space to hold src_size bytes
Exceptions
kzh::invalid_resourceif the file couldn't be DLed

Returns STAGE_OK on success, otherwise an error indicated by the return code, see karazeh/operation.hpp for a complete listing.

Implements kzh::operation.

References kzh::KARAZEH_EXPORT::cache_path, kzh::operation::config_, kzh::file_manager::create_directory(), kzh::logger::debug(), kzh::logger::deindent(), kzh::KARAZEH_EXPORT::downloader, dst_path, kzh::file_manager::ensure_directory(), kzh::logger::error(), kzh::file_manager::exists(), kzh::downloader::fetch(), kzh::KARAZEH_EXPORT::file_manager, kzh::release_manifest::id, kzh::logger::indent(), kzh::file_manager::is_readable(), kzh::file_manager::is_writable(), kzh::operation::rm_, kzh::KARAZEH_EXPORT::root_path, src_checksum, src_size, src_uri, kzh::STAGE_FILE_EXISTS, kzh::STAGE_OK, kzh::STAGE_UNAUTHORIZED, and kzh::KARAZEH_EXPORT::verbose.

Referenced by TEST_CASE().

string_t kzh::create_operation::tostring ( )
virtual

Used internally for exceptions and logging

Reimplemented from kzh::operation.

References dst_path, src_checksum, src_size, and src_uri.

Member Data Documentation

bool kzh::create_operation::is_executable
uint64_t kzh::create_operation::src_size
string_t kzh::create_operation::src_uri

The documentation for this class was generated from the following files: