X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/378a074c82bdb393b5780832598aaa1c648926b8..a039749b4c21e3439dc06fcdd5355828f1f95463:/backup.c diff --git a/backup.c b/backup.c index ee323f3f..6604f0b0 100644 --- a/backup.c +++ b/backup.c @@ -43,7 +43,7 @@ static int make_simple_backup(char *fname) if (do_rename(fname,fnamebak) != 0) { /* cygwin (at least version b19) reports EINVAL */ if (errno != ENOENT && errno != EINVAL) { - rprintf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno)); + rsyserr(FERROR, errno, "rename %s to backup %s", fname, fnamebak); return 0; } } else if (verbose > 1) { @@ -134,10 +134,14 @@ static int robust_move(char *src, char *dst) int failed; while (keep_trying) { - if (keep_path_extfs) - failed = copy_file (src, dst, 0755); - else + if (keep_path_extfs) { + failed = copy_file(src, dst, 0755); + if (!failed) { + do_unlink(src); + } + } else { failed = robust_rename (src, dst); + } if (failed) { if (verbose > 2) @@ -193,7 +197,10 @@ static int keep_backup(char *fname) if (do_stat (fname, &st)) return 1; #endif - file = make_file (0, fname); + file = make_file(-1, fname, NULL, 1); + + /* the file could have disappeared */ + if (!file) return 1; /* make a complete pathname for backup file */ if (strlen(backup_dir) + strlen(fname) > (MAXPATHLEN - 1)) {