Mercurial > gftp.yaz
diff src/gtk/transfer.c @ 76:fe308e435ed5
2002-12-4 Brian Masney <masneyb@gftp.org>
* lib/protocols.c (gftp_set_data_type) - return 0 if there is no
protocol specific set_data_type function
* src/gtk/transfer.c (gftp_gtk_transfer_files) - ascii/binary automatic
switching fixes
author | masneyb |
---|---|
date | Thu, 05 Dec 2002 00:43:07 +0000 |
parents | e2b30d0c97a4 |
children | 7ef60ce2bdb2 |
line wrap: on
line diff
--- a/src/gtk/transfer.c Wed Dec 04 02:36:05 2002 +0000 +++ b/src/gtk/transfer.c Thu Dec 05 00:43:07 2002 +0000 @@ -727,10 +727,9 @@ void * gftp_gtk_transfer_files (void *data) { - int i, mode, from_data_type, to_data_type; + int i, mode, dl_type, tofd, fromfd, old_from_datatype; gftp_transfer * transfer; char *tempstr, buf[8192]; - int tofd, fromfd; off_t fromsize, total; gftp_file * curfle; ssize_t num_read; @@ -741,13 +740,15 @@ gettimeofday (&transfer->starttime, NULL); memcpy (&transfer->lasttime, &transfer->starttime, sizeof (transfer->lasttime)); + + dl_type = transfer->fromreq->data_type; + old_from_datatype = transfer->fromreq->data_type; + while (transfer->curfle != NULL) { - from_data_type = to_data_type = -1; - pthread_mutex_lock (transfer->structmutex); curfle = transfer->curfle->data; - transfer->current_file_number++; + transfer->current_file_number++; pthread_mutex_unlock (transfer->structmutex); if (curfle->transfer_action == GFTP_TRANS_ACTION_SKIP) @@ -815,21 +816,27 @@ if (GFTP_IS_CONNECTED (transfer->fromreq) && GFTP_IS_CONNECTED (transfer->toreq)) { - if (curfle->ascii) + if (!curfle->ascii && old_from_datatype == GFTP_TYPE_BINARY) + dl_type = GFTP_TYPE_BINARY; + else + dl_type = GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII || curfle->ascii ? GFTP_TYPE_ASCII : GFTP_TYPE_BINARY; + + if (dl_type != transfer->fromreq->data_type) { - if (transfer->fromreq->data_type != GFTP_TYPE_ASCII) - { - from_data_type = transfer->fromreq->data_type; - gftp_set_data_type (transfer->fromreq, GFTP_TYPE_ASCII); - } + if (gftp_set_data_type (transfer->fromreq, dl_type) != 0) + gftp_disconnect (transfer->fromreq); + } - if (transfer->toreq->data_type != GFTP_TYPE_ASCII) - { - to_data_type = transfer->toreq->data_type; - gftp_set_data_type (transfer->toreq, GFTP_TYPE_ASCII); - } - } + if (dl_type != transfer->toreq->data_type) + { + if (gftp_set_data_type (transfer->toreq, dl_type) != 0) + gftp_disconnect (transfer->toreq); + } + } + if (GFTP_IS_CONNECTED (transfer->fromreq) && + GFTP_IS_CONNECTED (transfer->toreq)) + { fromsize = gftp_transfer_file (transfer->fromreq, curfle->file, fromfd, curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? @@ -837,15 +844,6 @@ transfer->toreq, curfle->destfile, tofd, curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? curfle->startsize : 0); - - if (curfle->ascii) - { - if (from_data_type != -1) - gftp_set_data_type (transfer->fromreq, from_data_type); - - if (to_data_type != -1) - gftp_set_data_type (transfer->toreq, to_data_type); - } } } @@ -891,8 +889,7 @@ total += num_read; gftp_gtk_calc_kbs (transfer, num_read); - if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII || - curfle->ascii) + if (dl_type == GFTP_TYPE_ASCII) tempstr = gftp_convert_ascii (buf, &num_read, 1); else tempstr = buf; @@ -906,8 +903,7 @@ /* We don't have to free tempstr for a download because new memory is not allocated for it in that case */ - if ((GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII || - curfle->ascii) && + if (dl_type == GFTP_TYPE_ASCII && transfer->transfer_direction == GFTP_DIRECTION_UPLOAD) g_free (tempstr); }