sum_update(data,i);
- if (fd != -1 && write_file(fd,data,i) != i) {
- rsyserr(FERROR, errno, "write failed on %s",
- full_fname(fname));
- exit_cleanup(RERR_FILEIO);
- }
+ if (fd != -1 && write_file(fd,data,i) != i)
+ goto report_write_error;
offset += i;
continue;
}
sum_update(map,len);
}
- if (!inplace || offset != offset2) {
- if (fd != -1 && write_file(fd, map, len) != (int)len) {
- rsyserr(FERROR, errno, "write failed on %s",
- full_fname(fname));
- exit_cleanup(RERR_FILEIO);
- }
- } else {
- flush_write_file(fd);
- if (do_lseek(fd,(OFF_T)len,SEEK_CUR) != offset+len) {
- rprintf(FERROR, "lseek failed on %s: %s, %lli, %lli, %i\n",
- full_fname(fname), strerror(errno),
- do_lseek(fd, 0, SEEK_CUR),
- offset + len, i);
- exit_cleanup(RERR_FILEIO);
+ if (inplace) {
+ if (offset == offset2 && fd != -1) {
+ if (flush_write_file(fd) < 0)
+ goto report_write_error;
+ offset += len;
+ if (do_lseek(fd, len, SEEK_CUR) != offset) {
+ rsyserr(FERROR, errno,
+ "lseek failed on %s",
+ full_fname(fname));
+ exit_cleanup(RERR_FILEIO);
+ }
+ continue;
}
}
+ if (fd != -1 && write_file(fd, map, len) != (int)len)
+ goto report_write_error;
offset += len;
}
flush_write_file(fd);
#ifdef HAVE_FTRUNCATE
- if (inplace)
+ if (inplace && fd != -1)
ftruncate(fd, offset);
#endif
end_progress(total_size);
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
+ report_write_error:
rsyserr(FERROR, errno, "write failed on %s",
full_fname(fname));
exit_cleanup(RERR_FILEIO);