Skip to content

Commit d535853

Browse files
derrickstoleedscho
authored andcommitted
gvfs-helper: do one read in my_copy_fd_len_tail()
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
1 parent 0288b11 commit d535853

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: gvfs-helper.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -2039,18 +2039,18 @@ static int my_copy_fd_len_tail(int fd_in, int fd_out, ssize_t nr_bytes_total,
20392039
{
20402040
memset(buf_tail, 0, tail_len);
20412041

2042+
if (my_copy_fd_len(fd_in, fd_out, nr_bytes_total) < 0)
2043+
return -1;
2044+
20422045
if (nr_bytes_total < tail_len)
2043-
return my_copy_fd_len(fd_in, fd_out, nr_bytes_total);
2046+
return 0;
20442047

2045-
if (my_copy_fd_len(fd_in, fd_out, (nr_bytes_total - tail_len)) < 0)
2046-
return -1;
2048+
/* Reset the position to read the tail */
2049+
lseek(fd_in, -tail_len, SEEK_CUR);
20472050

20482051
if (xread(fd_in, (char *)buf_tail, tail_len) != tail_len)
20492052
return -1;
20502053

2051-
if (write_in_full(fd_out, buf_tail, tail_len) < 0)
2052-
return -1;
2053-
20542054
return 0;
20552055
}
20562056

0 commit comments

Comments
 (0)