diff options
Diffstat (limited to 'scp.c')
-rw-r--r-- | scp.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -808,7 +808,7 @@ sink(int argc, char **argv) | |||
808 | size_t j, count; | 808 | size_t j, count; |
809 | int amt, exists, first, ofd; | 809 | int amt, exists, first, ofd; |
810 | mode_t mode, omode, mask; | 810 | mode_t mode, omode, mask; |
811 | off_t size, statbytes, writtenbytes; | 811 | off_t size, statbytes; |
812 | int setimes, targisdir, wrerrno = 0; | 812 | int setimes, targisdir, wrerrno = 0; |
813 | char ch, *cp, *np, *targ, *why, *vect[1], buf[2048]; | 813 | char ch, *cp, *np, *targ, *why, *vect[1], buf[2048]; |
814 | struct timeval tv[2]; | 814 | struct timeval tv[2]; |
@@ -978,7 +978,7 @@ bad: run_err("%s: %s", np, strerror(errno)); | |||
978 | cp = bp->buf; | 978 | cp = bp->buf; |
979 | wrerr = NO; | 979 | wrerr = NO; |
980 | 980 | ||
981 | statbytes = writtenbytes = 0; | 981 | statbytes = 0; |
982 | if (showprogress) | 982 | if (showprogress) |
983 | start_progress_meter(curfile, size, &statbytes); | 983 | start_progress_meter(curfile, size, &statbytes); |
984 | for (count = i = 0; i < size; i += 4096) { | 984 | for (count = i = 0; i < size; i += 4096) { |
@@ -1008,8 +1008,7 @@ bad: run_err("%s: %s", np, strerror(errno)); | |||
1008 | count) != count) { | 1008 | count) != count) { |
1009 | wrerr = YES; | 1009 | wrerr = YES; |
1010 | wrerrno = errno; | 1010 | wrerrno = errno; |
1011 | } else | 1011 | } |
1012 | writtenbytes += (off_t)count; | ||
1013 | } | 1012 | } |
1014 | count = 0; | 1013 | count = 0; |
1015 | cp = bp->buf; | 1014 | cp = bp->buf; |
@@ -1021,10 +1020,8 @@ bad: run_err("%s: %s", np, strerror(errno)); | |||
1021 | atomicio(vwrite, ofd, bp->buf, count) != count) { | 1020 | atomicio(vwrite, ofd, bp->buf, count) != count) { |
1022 | wrerr = YES; | 1021 | wrerr = YES; |
1023 | wrerrno = errno; | 1022 | wrerrno = errno; |
1024 | } else | 1023 | } |
1025 | writtenbytes += (off_t)count; | 1024 | if (wrerr == NO && ftruncate(ofd, size) != 0) { |
1026 | if (wrerr == NO && writtenbytes < size && | ||
1027 | ftruncate(ofd, size) != 0) { | ||
1028 | run_err("%s: truncate: %s", np, strerror(errno)); | 1025 | run_err("%s: truncate: %s", np, strerror(errno)); |
1029 | wrerr = DISPLAYED; | 1026 | wrerr = DISPLAYED; |
1030 | } | 1027 | } |