return OKAY;
}
-bool heavy_file_operations::advance(const filename_list &to_transfer,
+basis::outcome heavy_file_operations::advance(const filename_list &to_transfer,
file_transfer_header &last_action)
{
#ifdef DEBUG_HEAVY_FILE_OPS
FUNCDEF("advance");
#endif
int indy = to_transfer.locate(last_action._filename);
- if (negative(indy)) return false; // error.
- if (indy == to_transfer.elements() - 1) return false; // done.
+ if (negative(indy)) return BAD_INPUT; // error, file not found in list.
+ if (indy == to_transfer.elements() - 1) return FINISHED; // done.
const file_info *currfile = to_transfer.get(indy + 1);
last_action._filename = currfile->raw();
last_action._time = currfile->_time;
last_action._byte_start = 0;
last_action._length = 0;
- return true;
+ return OKAY;
}
outcome heavy_file_operations::buffer_files(const astring &source_root,
if (!current.good()) {
// we need to skip this file.
LOG(astring("skipping bad file: ") + full_file);
- if (!advance(to_transfer, last_action)) break;
+ to_return = advance(to_transfer, last_action);
+ if (to_return != OKAY) break;
continue;
}
if (last_action._byte_start + last_action._length >= current.length()) {
-LOG(astring("finished handling file: ") + full_file);
+LOG(astring("finished stuffing file: ") + full_file);
// this file is done now. go to the next one.
- if (!advance(to_transfer, last_action)) break;
+ to_return = advance(to_transfer, last_action);
+ if (to_return != OKAY) break;
continue;
}
if (bytes_read != new_len) {
if (!bytes_read) {
// some kind of problem reading the file.
- if (!advance(to_transfer, last_action)) break;
+ to_return = advance(to_transfer, last_action);
+ if (to_return != OKAY) break;
continue;
}
//why would this happen? just complain, i guess.
if (!current.length()) {
// ensure we don't get stuck redoing zero length files, which we allowed
// to go past their end above (since otherwise we'd never see them).
- if (!advance(to_transfer, last_action)) break;
+ to_return = advance(to_transfer, last_action);
+ if (to_return != OKAY) break;
continue;
}
(_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!");
+ // finish by setting command to be a conclude marker.
the_rec->_done = true;
resp->_command = file_transfer_infoton::CONCLUDE_TRANSFER_MARKER;
bufret = OKAY; // now it's no longer an exceptional outcome.
+ 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);