36 using namespace basis;
45 #define DEBUG_RECURSIVE_FILE_COPY
48 #define FAKE_HOSTNAME "internal_fake_host"
51 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
53 #define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger::get(), s)
55 #define RETURN_ERROR_RFC(msg, err) { \
68 recursive_file_copy::~recursive_file_copy() {}
70 const char *recursive_file_copy::outcome_name(
const outcome &to_name)
71 {
return common::outcome_name(to_name); }
73 outcome recursive_file_copy::copy_hierarchy(
int transfer_mode,
88 const astring transfer_name =
"snootums";
90 astring source_root = transfer_name;
91 if (source_start.
t()) {
92 source_root += filename::default_separator() + source_start;
102 if (add_ret != tentacle::OKAY)
108 initiate->
_command = file_transfer_infoton::BUILD_TARGET_TREE;
119 if (start_ret != tentacle::OKAY)
124 if (!reply_from_init) {
125 LOG(
"spewing list of what IS there...");
127 RETURN_ERROR_RFC(
"no response to request to build target tree", NONE_READY);
130 if (reply_from_init->
_success != OKAY) {
139 comparison_req->
_command = file_transfer_infoton::TREE_COMPARISON;
146 target_area.
calculate( !(transfer_mode & file_transfer_tentacle::COMPARE_CONTENT_SAMPLE) );
152 start_ret = ring_leader.
evaluate(comparison_req, req_id);
153 if (start_ret != tentacle::OKAY)
157 if (!reply_from_init) {
158 LOG(
"spewing list of what IS there...");
160 RETURN_ERROR_RFC(
"no response to request to build target tree", NONE_READY);
169 if (!diffs.
unpack(pack_copy)) {
181 outcome ini_resp_ret = client_spider.
evaluate(reply_from_init, resp_id);
182 if (ini_resp_ret != tentacle::OKAY)
193 #ifdef DEBUG_RECURSIVE_FILE_COPY
200 ongoing->
_command = file_transfer_infoton::PLACE_FILE_CHUNKS;
206 if (place_ret != tentacle::OKAY)
210 .acquire_specific_result(chunk_id);
214 if (reply->
_command == file_transfer_infoton::CONCLUDE_TRANSFER_MARKER) {
216 +
"\" to \"" + target_dir +
"\"");
221 while (
copy.length()) {
240 if (resp_ret != tentacle::OKAY)
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
bool t() const
t() is a shortcut for the string being "true", as in non-empty.
A very common template for a dynamic array of bytes.
Outcomes describe the state of completion for an operation.
An object that traverses directory trees and provides a view of all files.
bool calculate(bool just_size)
visits each file in the directory_tree and calculates its attributes.
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
basis::astring text_form() const
Base objects used by the file transfer tentacle to schedule transfers.
basis::abyte _command
one of the commands above.
basis::outcome _success
reports what kind of result occurred.
basis::astring _src_root
the top-level directory of the source.
bool _request
if it's not a request, then it's a response.
basis::astring _dest_root
the top-level directory of the destination.
void package_tree_info(const filesystem::directory_tree &tree, const structures::string_array &includes)
prepares the packed data from the "tree" and "includes" list.
basis::byte_array _packed_data
the packed headers and file chunks.
Manages the transferrence of directory trees from one place to another.
basis::outcome add_correspondence(const basis::astring &source_mapping, const basis::astring &source_root, int refresh_interval)
adds a file transfer correspondence.
basis::outcome register_file_transfer(const octopus_entity &ent, const basis::astring &src_root, const basis::astring &dest_root, const structures::string_array &include)
records a transfer that is going to commence.
An infoton is an individual request parcel with accompanying information.
Provides a way of identifying users of an octopus object.
Identifies requests made on an octopus by users.
Octopus is a design pattern for generalized request processing systems.
entity_data_bin & responses()
allows external access to our set of results.
basis::outcome add_tentacle(tentacle *to_add, bool filter=false)
hooks a tentacle in to provide processing of one type of infoton.
basis::outcome evaluate(infoton *request, const octopus_request_id &item_id, bool now=false)
tries to process the "request" using the current set of tentacles.
octopus_entity issue_identity()
creates an entity identifier that is unique for this octopus.
infoton * acquire_specific_result(const octopus_request_id &original_id)
supports seeking the result for a specific request.
An array of strings with some additional helpful methods.
char * copy(register char *str)
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
const int MEGABYTE
Number of bytes in a megabyte.
const int HOUR_ms
Number of milliseconds in an hour.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
const int MAX_CHUNK_RFC_COPY_HIER
const int EXPECTED_MAXIMUM_TRANSFER_TIME
A dynamic container class that holds any kind of object via pointers.
#define RETURN_ERROR_RFC(msg, err)