X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=octopi%2Flibrary%2Ftentacles%2Ffile_transfer_tentacle.cpp;h=50cc5114b5ea97b1499d48e30d10417d868d6434;hb=5147de169ea3616475f5cf6a48b6741e5279242f;hp=717d276120d5c3c396fd3c0e00917b2e398e8f92;hpb=8d5adf2438ee63c6ee88ca9a42aea2d763f0b03d;p=feisty_meow.git diff --git a/octopi/library/tentacles/file_transfer_tentacle.cpp b/octopi/library/tentacles/file_transfer_tentacle.cpp index 717d2761..50cc5114 100644 --- a/octopi/library/tentacles/file_transfer_tentacle.cpp +++ b/octopi/library/tentacles/file_transfer_tentacle.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -136,9 +137,10 @@ public: // turns a source mapping into the location that it corresponds to. astring translate(const astring &source_path) const { -// FUNCDEF("translate"); + FUNCDEF("translate"); string_array pieces; - filename(source_path).separate(pieces); + bool rooted; + filename(source_path).separate(rooted, pieces); astring source_mapping = pieces[0]; pieces.zap(0, 0); // remove source part. @@ -273,14 +275,14 @@ outcome file_transfer_tentacle::add_correspondence } #ifdef DEBUG_FILE_TRANSFER_TENTACLE LOG(astring("adding tree for: ent=") + new_record->_ent.text_form() - + " src=" + new_record->_src_root + " dest=" + new_record->_dest_root); + + " src=" + new_record->_src_root); #endif // calculate size and checksum info for the directory. new_record->_local_dir->calculate( !(_mode & COMPARE_CONTENT_SAMPLE) ); #ifdef DEBUG_FILE_TRANSFER_TENTACLE LOG(astring("done adding tree for: ent=") + new_record->_ent.text_form() - + " src=" + new_record->_src_root + " dest=" + new_record->_dest_root); + + " src=" + new_record->_src_root); #endif _correspondences->append(new_record); @@ -300,7 +302,7 @@ outcome file_transfer_tentacle::remove_correspondence bool file_transfer_tentacle::get_differences(const octopus_entity &ent, const astring &src, const astring &dest, filename_list &diffs) { -// FUNCDEF("get_differences"); + FUNCDEF("get_differences"); diffs.reset(); AUTO_LOCK; file_transfer_record *the_rec = _transfers->find(ent, src, dest); @@ -315,7 +317,7 @@ bool file_transfer_tentacle::status(const octopus_entity &ent, int &total_files, double ¤t_size, int ¤t_files, bool &done, time_stamp &last_active) { -// FUNCDEF("status"); + FUNCDEF("status"); total_size = 0; total_files = 0; current_files = 0; @@ -466,13 +468,14 @@ outcome file_transfer_tentacle::handle_tree_compare_request // get the mapping from the specified location on this side. filename splitting(req._src_root); string_array pieces; - splitting.separate(pieces); + bool rooted; + splitting.separate(rooted, pieces); astring source_mapping = pieces[0]; // patch the name up to find the sub_path for the source. filename source_start; pieces.zap(0, 0); - source_start.join(pieces); + source_start.join(rooted, pieces); // locate the allowed transfer depot for the mapping they provided. file_transfer_record *mapping_record @@ -556,9 +559,13 @@ outcome file_transfer_tentacle::handle_tree_compare_request // before the client starts the transfer. reply->_request = false; // it's a response now. +LOG("storing product from transfer processing"); store_product(reply, item_id); // send back the comparison list. +LOG("now showing bin before return:"); +LOG(get_storage()->text_form()); + return OKAY; } @@ -620,11 +627,12 @@ outcome file_transfer_tentacle::handle_storage_request (_correspondences->translate(the_rec->_src_root), *the_rec->_diffs, the_rec->_last_sent, resp->_packed_data, _maximum_transfer); if (bufret == heavy_file_operations::FINISHED) { -//here we go. finish by setting command to conclude. -LOG("got the final marker saying heavy file ops done!"); - the_rec->_done = true; - resp->_command = file_transfer_infoton::CONCLUDE_TRANSFER_MARKER; - bufret = OKAY; // now it's no longer an exceptional outcome. + bufret = OKAY; // in either case, we don't emit a finished outcome; handled elsewhere. + if (!resp->_packed_data.length()) { + // blank packages, so finish by setting command to be a conclude marker. + the_rec->_done = true; + resp->_command = file_transfer_infoton::CONCLUDE_TRANSFER_MARKER; + } } else if (bufret != OKAY) { // complain, but still send. LOG(astring("buffer files returned an error on item=") @@ -632,16 +640,13 @@ LOG("got the final marker saying heavy file ops done!"); + req._dest_root); } -// if ( (bufret == OKAY) && !resp->_packed_data.length() ) { -// LOG(astring("failed to pack any data for file: ") + req._src_root); -// } - - if (!the_rec->_done && (bufret == OKAY) && !resp->_packed_data.length() ) { - // seems like the transfer is done. +//can remove this block if stops saying it. + if ((bufret == OKAY) && !resp->_packed_data.length() ) { LOG("marking empty transfer as done; why not caught above at FINISHED check?"); the_rec->_done = true; resp->_command = file_transfer_infoton::CONCLUDE_TRANSFER_MARKER; } +//end of can remove. resp->_request = false; // it's a response now. store_product(resp, item_id); @@ -700,6 +705,7 @@ outcome file_transfer_tentacle::handle_storage_response astring full_file = resp._dest_root + filename::default_separator() + recorded_info->secondary(); +LOG(astring("telling it to write to fullfile: ") + full_file); outcome ret = heavy_file_operations::write_file_chunk(full_file, found._byte_start, to_write); @@ -718,7 +724,7 @@ outcome file_transfer_tentacle::handle_storage_response outcome file_transfer_tentacle::conclude_storage_request (file_transfer_infoton &req, const octopus_request_id &item_id) { - FUNCDEF("handle_storage_request"); + FUNCDEF("conclude_storage_request"); if (_mode & ONLY_REPORT_DIFFS) { // store an unhandled infoton. unhandled_request *deny = new unhandled_request(item_id, req.classifier(), NO_HANDLER); @@ -745,13 +751,17 @@ outcome file_transfer_tentacle::conclude_storage_request the_rec->_done = true; // we're concluding the transfer, so that's that. resp->_request = false; // it's a response now. store_product(resp, item_id); + + LOG(astring("concluding transfer request on src=") + req._src_root + " dest=" + + req._dest_root); + return common::OKAY; } outcome file_transfer_tentacle::conclude_storage_response (file_transfer_infoton &resp, const octopus_request_id &item_id) { - FUNCDEF("handle_storage_response"); + FUNCDEF("conclude_storage_response"); if (_mode & ONLY_REPORT_DIFFS) { // not spoken here. return NO_HANDLER; @@ -767,6 +777,9 @@ outcome file_transfer_tentacle::conclude_storage_response // mark that we're done now. the_rec->_done = true; + LOG(astring("concluding transfer response on src=") + resp._src_root + " dest=" + + resp._dest_root); + // there is no response product to store. return OKAY; }