aboutsummaryrefslogtreecommitdiffstats
path: root/rsync.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2006-01-30 07:18:13 +0000
committerWayne Davison <wayned@samba.org>2006-01-30 07:18:13 +0000
commitd8b1c923efd14d320f90884901b795f141aa6464 (patch)
tree335ede910e673f8295f5ce07a3e7ab6f23361b51 /rsync.c
parent4a4d2b1ba0871c185acb4d7b8db793ea9474e7e7 (diff)
downloadandroid_external_rsync-d8b1c923efd14d320f90884901b795f141aa6464.tar.gz
android_external_rsync-d8b1c923efd14d320f90884901b795f141aa6464.tar.bz2
android_external_rsync-d8b1c923efd14d320f90884901b795f141aa6464.zip
The finish_transfer() function now takes a "partialptr" arg that, if
non-NULL, will be used if robust_rename() is forced to copy the temp file.
Diffstat (limited to 'rsync.c')
-rw-r--r--rsync.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/rsync.c b/rsync.c
index 661f9904..68d5026e 100644
--- a/rsync.c
+++ b/rsync.c
@@ -149,7 +149,6 @@ int set_file_attrs(char *fname, struct file_struct *file, STRUCT_STAT *st,
return updated;
}
-
void sig_int(void)
{
/* KLUGE: if the user hits Ctrl-C while ssh is prompting
@@ -164,17 +163,20 @@ void sig_int(void)
exit_cleanup(RERR_SIGNAL);
}
-
-/* finish off a file transfer, renaming the file and setting the permissions
- and ownership */
-void finish_transfer(char *fname, char *fnametmp, struct file_struct *file,
- int ok_to_set_time, int overwriting_basis)
+/* Finish off a file transfer: renaming the file and setting the file's
+ * attributes (e.g. permissions, ownership, etc.). If partialptr is not
+ * NULL and the robust_rename() call is forced to copy the temp file, we
+ * stage the file into the partial-dir and then rename it into place. */
+void finish_transfer(char *fname, char *fnametmp, char *partialptr,
+ struct file_struct *file, int ok_to_set_time,
+ int overwriting_basis)
{
int ret;
if (inplace) {
if (verbose > 2)
rprintf(FINFO, "finishing %s\n", fname);
+ fnametmp = fname;
goto do_set_file_attrs;
}
@@ -188,7 +190,8 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file,
/* move tmp file over real file */
if (verbose > 2)
rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
- ret = robust_rename(fnametmp, fname, file->mode & INITACCESSPERMS);
+ ret = robust_rename(fnametmp, fname, partialptr,
+ file->mode & INITACCESSPERMS);
if (ret < 0) {
rsyserr(FERROR, errno, "%s %s -> \"%s\"",
ret == -2 ? "copy" : "rename",
@@ -200,9 +203,21 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file,
/* The file was moved into place (not copied), so it's done. */
return;
}
+ /* The file was copied, so tweak the perms of the copied file. If it
+ * was copied to partialptr, move it into its final destination. */
+ fnametmp = partialptr ? partialptr : fname;
+
do_set_file_attrs:
- set_file_attrs(fname, file, NULL,
+ set_file_attrs(fnametmp, file, NULL,
ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
+
+ if (partialptr) {
+ if (do_rename(fnametmp, fname) < 0) {
+ rsyserr(FERROR, errno, "rename %s -> \"%s\"",
+ full_fname(fnametmp), fname);
+ } else
+ handle_partial_dir(partialptr, PDIR_DELETE);
+ }
}
const char *who_am_i(void)