|
Lines 745-751
do_download(struct sftp_conn *conn, char
Link Here
|
| 745 |
char *handle; |
745 |
char *handle; |
| 746 |
int local_fd, status, num_req, max_req, write_error; |
746 |
int local_fd, status, num_req, max_req, write_error; |
| 747 |
int read_error, write_errno; |
747 |
int read_error, write_errno; |
| 748 |
u_int64_t offset, size; |
748 |
u_int64_t offset, size, highwater; |
| 749 |
u_int handle_len, mode, type, id, buflen; |
749 |
u_int handle_len, mode, type, id, buflen; |
| 750 |
off_t progress_counter; |
750 |
off_t progress_counter; |
| 751 |
struct request { |
751 |
struct request { |
|
Lines 812-817
do_download(struct sftp_conn *conn, char
Link Here
|
| 812 |
|
812 |
|
| 813 |
/* Read from remote and write to local */ |
813 |
/* Read from remote and write to local */ |
| 814 |
write_error = read_error = write_errno = num_req = offset = 0; |
814 |
write_error = read_error = write_errno = num_req = offset = 0; |
|
|
815 |
highwater = 0; |
| 815 |
max_req = 1; |
816 |
max_req = 1; |
| 816 |
progress_counter = 0; |
817 |
progress_counter = 0; |
| 817 |
|
818 |
|
|
Lines 887-893
do_download(struct sftp_conn *conn, char
Link Here
|
| 887 |
write_errno = errno; |
888 |
write_errno = errno; |
| 888 |
write_error = 1; |
889 |
write_error = 1; |
| 889 |
max_req = 0; |
890 |
max_req = 0; |
| 890 |
} |
891 |
} else if (req->offset <= highwater) |
|
|
892 |
highwater = req->offset + len; |
| 893 |
|
| 891 |
progress_counter += len; |
894 |
progress_counter += len; |
| 892 |
xfree(data); |
895 |
xfree(data); |
| 893 |
|
896 |
|
|
Lines 936-941
do_download(struct sftp_conn *conn, char
Link Here
|
| 936 |
/* Sanity check */ |
939 |
/* Sanity check */ |
| 937 |
if (TAILQ_FIRST(&requests) != NULL) |
940 |
if (TAILQ_FIRST(&requests) != NULL) |
| 938 |
fatal("Transfer complete, but requests still in queue"); |
941 |
fatal("Transfer complete, but requests still in queue"); |
|
|
942 |
|
| 943 |
/* Truncate at highest contiguous point to avoid holes on interrupt */ |
| 944 |
if (read_error || write_error || interrupted) { |
| 945 |
debug("truncating at %llu", highwater); |
| 946 |
ftruncate(local_fd, highwater); |
| 947 |
} |
| 939 |
|
948 |
|
| 940 |
if (read_error) { |
949 |
if (read_error) { |
| 941 |
error("Couldn't read from remote file \"%s\" : %s", |
950 |
error("Couldn't read from remote file \"%s\" : %s", |