updated version
[feisty_meow.git] / octopi / applications / transporter / transporter.cpp
index e6cc082ad64f9b1ca949c4c978017dd6449ef7c9..3da636d9cdf592a184a9cafe5a807701baf74f4d 100644 (file)
@@ -93,8 +93,8 @@ private:
 transporter::transporter()
 : application_shell(),
   _saw_clients(false),
-  _server_side(NIL),
-  _client_side(NIL),
+  _server_side(NULL_POINTER),
+  _client_side(NULL_POINTER),
   _leave_when_no_clients(false),
   _encryption(false),
   _started_okay(false)
@@ -253,20 +253,32 @@ int transporter::push_client_download()
   // prepare a client request
   file_transfer_infoton initiate;
   initiate._request = true;
-  initiate._command = file_transfer_infoton::TREE_COMPARISON;
+  initiate._command = file_transfer_infoton::BUILD_TARGET_TREE;
   initiate._src_root = _source;
   initiate._dest_root = _target;
+
+  // make a directory snapshot with just directories, no files.
+  directory_tree target_area_just_dirs(_target, "*", true);
+  string_set includes;
+  initiate.package_tree_info(target_area_just_dirs, includes);
+  octopus_request_id cmd_id;
+  outcome build_ret = _client_side->submit(initiate, cmd_id);
+  if (build_ret != tentacle::OKAY)
+    non_continuable_error(class_name(), func, astring("failed to build the "
+        " target tree: ") + cromp_client::outcome_name(build_ret));
+
+  // now get the full contents going on.
+  initiate._command = file_transfer_infoton::TREE_COMPARISON;
   directory_tree target_area(_target);
   target_area.calculate(false);
-  string_set includes;
+  includes.reset();
   initiate.package_tree_info(target_area, includes);
-  octopus_request_id cmd_id;
   outcome start_ret = _client_side->submit(initiate, cmd_id);
   if (start_ret != tentacle::OKAY)
     non_continuable_error(class_name(), func, astring("failed to initiate "
         " the transfer: ") + cromp_client::outcome_name(start_ret));
 
-  infoton *start_reply_tmp = NIL;
+  infoton *start_reply_tmp = NULL_POINTER;
 //hmmm: set timeout appropriate to the speed of the connection!
   outcome first_receipt = _client_side->acquire(start_reply_tmp, cmd_id);
   if (first_receipt != cromp_client::OKAY)
@@ -308,7 +320,7 @@ LOG(a_sprintf("ongoing chunk %d", ++iter));
       non_continuable_error(class_name(), func, astring("failed to send ongoing "
           "chunk: ") + cromp_client::outcome_name(place_ret));
 
-    infoton *place_reply_tmp = NIL;
+    infoton *place_reply_tmp = NULL_POINTER;
 //hmmm: set timeout appropriate to the speed of the connection!
     outcome place_receipt = _client_side->acquire(place_reply_tmp, cmd_id);
     if (place_receipt != cromp_client::OKAY)