Delay the renaming of all the temp files until the end of the transfer.
---- orig/options.c 2005-01-17 23:11:45
-+++ options.c 2005-01-17 23:15:13
-@@ -97,6 +97,7 @@ int modify_window = 0;
+--- orig/options.c 2005-01-23 01:45:43
++++ options.c 2005-01-23 07:27:59
+@@ -99,6 +99,7 @@ int modify_window = 0;
int blocking_io = -1;
int checksum_seed = 0;
int inplace = 0;
long block_size = 0; /* "long" because popt can't set an int32. */
-@@ -278,6 +279,7 @@ void usage(enum logcode F)
- rprintf(F," --max-size=SIZE don't transfer any file larger than SIZE\n");
- rprintf(F," --partial keep partially transferred files\n");
- rprintf(F," --partial-dir=DIR put a partially transferred file into DIR\n");
+@@ -273,6 +274,7 @@ void usage(enum logcode F)
+ rprintf(F," --rsync-path=PATH specify path to rsync on the remote machine\n");
+ rprintf(F," --existing only update files that already exist\n");
+ rprintf(F," --ignore-existing ignore files that already exist on receiving side\n");
+ rprintf(F," --delay-renames renames transferred files into place at end\n");
- rprintf(F," --force force deletion of directories even if not empty\n");
- rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n");
- rprintf(F," --timeout=TIME set I/O timeout in seconds\n");
-@@ -390,6 +392,7 @@ static struct poptOption long_options[]
+ rprintf(F," --delete delete files that don't exist on the sending side\n");
+ rprintf(F," --delete-after receiver deletes after transferring, not before\n");
+ rprintf(F," --delete-excluded also delete excluded files on the receiving side\n");
+@@ -394,6 +396,7 @@ static struct poptOption long_options[]
{"progress", 0, POPT_ARG_NONE, &do_progress, 0, 0, 0 },
{"partial", 0, POPT_ARG_NONE, &keep_partial, 0, 0, 0 },
{"partial-dir", 0, POPT_ARG_STRING, &partial_dir, 0, 0, 0 },
{"ignore-errors", 0, POPT_ARG_NONE, &ignore_errors, 0, 0, 0 },
{"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 },
{"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 },
-@@ -944,11 +947,15 @@ int parse_arguments(int *argc, const cha
+@@ -948,11 +951,15 @@ int parse_arguments(int *argc, const cha
bwlimit_writemax = 512;
}
return 0;
}
keep_partial = 0;
-@@ -1179,6 +1186,8 @@ void server_options(char **args,int *arg
+@@ -1187,6 +1194,8 @@ void server_options(char **args,int *arg
if (partial_dir && am_sender) {
args[ac++] = "--partial-dir";
args[ac++] = partial_dir;
} else if (keep_partial)
args[ac++] = "--partial";
---- orig/receiver.c 2005-01-17 23:11:45
+--- orig/receiver.c 2005-01-23 07:27:24
+++ receiver.c 2005-01-10 10:16:54
@@ -53,6 +53,7 @@ extern int orig_umask;
extern int keep_partial;
extern struct exclude_list_struct server_exclude_list;
-@@ -345,6 +346,7 @@ int recv_files(int f_in, struct file_lis
+@@ -324,6 +325,7 @@ int recv_files(int f_in, struct file_lis
char fnametmp[MAXPATHLEN];
char *fnamecmp, *partialptr;
char fnamecmpbuf[MAXPATHLEN];
struct file_struct *file;
struct stats initial_stats;
int save_make_backups = make_backups;
-@@ -358,6 +360,12 @@ int recv_files(int f_in, struct file_lis
+@@ -337,6 +339,12 @@ int recv_files(int f_in, struct file_lis
flist->hlink_pool = NULL;
}
while (1) {
cleanup_disable();
-@@ -572,7 +580,7 @@ int recv_files(int f_in, struct file_lis
+@@ -551,7 +559,7 @@ int recv_files(int f_in, struct file_lis
exit_cleanup(RERR_FILEIO);
}
finish_transfer(fname, fnametmp, file, recv_ok, 1);
if (partialptr != fname && fnamecmp == partialptr) {
do_unlink(partialptr);
-@@ -582,6 +590,8 @@ int recv_files(int f_in, struct file_lis
+@@ -561,6 +569,8 @@ int recv_files(int f_in, struct file_lis
&& handle_partial_dir(partialptr, PDIR_CREATE)) {
finish_transfer(partialptr, fnametmp, file, recv_ok,
!partial_dir);
} else {
partialptr = NULL;
do_unlink(fnametmp);
-@@ -621,6 +631,33 @@ int recv_files(int f_in, struct file_lis
+@@ -600,6 +610,33 @@ int recv_files(int f_in, struct file_lis
}
make_backups = save_make_backups;
if (delete_after && recurse && !local_name && flist->count > 0)
delete_files(flist);
---- orig/rsync.yo 2005-01-17 23:11:46
-+++ rsync.yo 2005-01-17 23:13:23
-@@ -348,6 +348,7 @@ verb(
- --max-size=SIZE don't transfer any file larger than SIZE
- --partial keep partially transferred files
- --partial-dir=DIR put a partially transferred file into DIR
+--- orig/rsync.yo 2005-01-22 22:48:52
++++ rsync.yo 2005-01-23 07:28:13
+@@ -340,6 +340,7 @@ verb(
+ --rsync-path=PATH specify path to rsync on the remote machine
+ --existing only update files that already exist
+ --ignore-existing ignore files that already exist on receiver
+ --delay-renames renames transferred files into place at end
- --force force deletion of dirs even if not empty
- --numeric-ids don't map uid/gid values by user/group name
- --timeout=TIME set I/O timeout in seconds
+ --delete delete files that don't exist on sender
+ --delete-after receiver deletes after transfer, not before
+ --delete-excluded also delete excluded files on receiver
@@ -546,9 +547,9 @@ or appended data, and also on systems th
bound.
}
if (verbose > 2)
---- orig/main.c 2005-01-22 22:48:52
+--- orig/main.c 2005-01-23 07:27:24
+++ main.c 2005-01-23 01:48:52
-@@ -737,6 +737,8 @@ int client_run(int f_in, int f_out, pid_
+@@ -736,6 +736,8 @@ int client_run(int f_in, int f_out, pid_
if (!read_batch)
send_exclude_list(f_out);
args[ac++] = "--delete";
if (delete_after)
---- orig/receiver.c 2005-01-22 22:48:52
-+++ receiver.c 2005-01-23 01:50:42
-@@ -21,8 +21,8 @@
- #include "rsync.h"
-
+--- orig/receiver.c 2005-01-23 07:27:24
++++ receiver.c 2005-01-23 07:29:29
+@@ -23,7 +23,6 @@
extern int verbose;
-+extern int recurse;
+ extern int recurse;
extern int delete_after;
-extern int max_delete;
extern int csum_length;
extern struct stats stats;
extern int dry_run;
-@@ -35,7 +35,6 @@ extern int keep_dirs;
+@@ -35,7 +34,6 @@ extern int relative_paths;
extern int keep_dirlinks;
extern int preserve_hard_links;
extern int preserve_perms;
extern int io_error;
extern char *tmpdir;
extern char *partial_dir;
-@@ -43,9 +42,6 @@ extern char *basis_dir[];
+@@ -43,9 +41,6 @@ extern char *basis_dir[];
extern int basis_dir_cnt;
extern int make_backups;
extern int do_progress;
extern int cleanup_got_literal;
extern int module_id;
extern int ignore_errors;
-@@ -57,66 +53,19 @@ extern int inplace;
+@@ -57,66 +52,19 @@ extern int inplace;
extern struct exclude_list_struct server_exclude_list;
..wayne..
---- orig/clientserver.c 2005-01-01 21:11:00
+--- orig/clientserver.c 2005-01-22 22:48:52
+++ clientserver.c 2005-01-16 23:33:02
@@ -49,12 +49,14 @@ extern int no_detach;
extern int default_af_hint;
/**
* Run a client connected to an rsyncd. The alternative to this
* function for remote-shell connections is do_cmd().
-@@ -304,26 +306,33 @@ static int rsync_module(int f_in, int f_
+@@ -310,26 +312,33 @@ static int rsync_module(int f_in, int f_
/* TODO: Perhaps take a list of gids, and make them into the
* supplementary groups. */
log_init();
---- orig/exclude.c 2005-01-13 23:15:56
-+++ exclude.c 2005-01-17 05:55:59
+--- orig/exclude.c 2005-01-22 22:48:52
++++ exclude.c 2005-01-23 07:33:21
@@ -30,15 +30,68 @@ extern int verbose;
extern int eol_nulls;
extern int list_only;
while (1) {
char *s = line;
-@@ -388,7 +862,7 @@ void send_exclude_list(int f)
- * FIXME: This pattern shows up in the output of
- * report_exclude_result(), which is not ideal. */
- if (list_only && !recurse)
+@@ -386,7 +860,7 @@ void send_exclude_list(int f)
+ /* This is a complete hack - blame Rusty. FIXME!
+ * Remove this hack when older rsyncs (below 2.6.4) are gone. */
+ if (list_only == 1 && !recurse)
- add_exclude(&exclude_list, "/*/*", 0);
+ add_exclude(&exclude_list, "/*/*", XFLG_DEF_EXCLUDE);
for (ent = exclude_list.head; ent; ent = ent->next) {
unsigned int l;
-@@ -402,10 +876,34 @@ void send_exclude_list(int f)
+@@ -400,10 +874,34 @@ void send_exclude_list(int f)
p[l] = '\0';
}
write_int(f, l + 2);
write_buf(f, "- ", 2);
} else
-@@ -419,14 +917,15 @@ void send_exclude_list(int f)
+@@ -417,14 +915,15 @@ void send_exclude_list(int f)
void recv_exclude_list(int f)
{
}
}
-@@ -443,18 +942,18 @@ static char default_cvsignore[] =
+@@ -441,18 +940,18 @@ static char default_cvsignore[] =
void add_cvs_excludes(void)
{
- XFLG_WORD_SPLIT | XFLG_WORDS_ONLY);
+ add_exclude(&exclude_list, getenv("CVSIGNORE"), cvs_flags);
}
---- orig/flist.c 2005-01-21 00:35:26
+--- orig/flist.c 2005-01-22 22:48:52
+++ flist.c 2004-08-12 18:59:28
@@ -40,11 +40,10 @@ extern int module_id;
extern int ignore_errors;
}
}
-@@ -1002,6 +987,7 @@ static void send_directory(int f, struct
+@@ -1004,6 +989,7 @@ static void send_directory(int f, struct
struct dirent *di;
char fname[MAXPATHLEN];
unsigned int offset;
char *p;
d = opendir(dir);
-@@ -1025,18 +1011,7 @@ static void send_directory(int f, struct
+@@ -1027,18 +1013,7 @@ static void send_directory(int f, struct
offset++;
}
for (errno = 0, di = readdir(d); di; errno = 0, di = readdir(d)) {
char *dname = d_name(di);
-@@ -1057,6 +1032,8 @@ static void send_directory(int f, struct
+@@ -1060,6 +1035,8 @@ static void send_directory(int f, struct
rsyserr(FERROR, errno, "readdir(%s)", dir);
}
closedir(d);
}
-@@ -1076,6 +1053,7 @@ struct file_list *send_file_list(int f,
+@@ -1079,6 +1056,7 @@ struct file_list *send_file_list(int f,
char *p, *dir, olddir[sizeof curr_dir];
char lastpath[MAXPATHLEN] = "";
struct file_list *flist;
int64 start_write;
int use_ff_fd = 0;
-@@ -1096,6 +1074,10 @@ struct file_list *send_file_list(int f,
+@@ -1099,6 +1077,10 @@ struct file_list *send_file_list(int f,
exit_cleanup(RERR_FILESELECT);
}
use_ff_fd = 1;
}
}
-@@ -1126,6 +1108,15 @@ struct file_list *send_file_list(int f,
- }
- }
+@@ -1135,6 +1117,15 @@ struct file_list *send_file_list(int f,
+ } else if (recurse > 0)
+ recurse = 0;
+ if (need_first_push) {
+ if ((p = strrchr(fname, '/')) != NULL) {
FN_LOCAL_STRING(lp_exclude, exclude)
FN_LOCAL_STRING(lp_exclude_from, exclude_from)
FN_LOCAL_STRING(lp_include, include)
---- orig/options.c 2005-01-20 23:05:34
-+++ options.c 2005-01-16 23:34:15
-@@ -145,6 +145,7 @@ int list_only = 0;
+--- orig/options.c 2005-01-23 01:45:43
++++ options.c 2005-01-23 07:33:55
+@@ -146,6 +146,7 @@ int list_only = 0;
char *batch_name = NULL;
static int daemon_opt; /* sets am_daemon after option error-reporting */
static int modify_window_set;
static char *dest_option = NULL;
static char *max_size_arg;
-@@ -292,6 +293,9 @@ void usage(enum logcode F)
+@@ -294,6 +295,9 @@ void usage(enum logcode F)
rprintf(F," -P equivalent to --partial --progress\n");
rprintf(F," -z, --compress compress file data\n");
rprintf(F," -C, --cvs-exclude auto ignore files in the same way CVS does\n");
rprintf(F," --exclude=PATTERN exclude files matching PATTERN\n");
rprintf(F," --exclude-from=FILE exclude patterns listed in FILE\n");
rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n");
-@@ -321,7 +325,7 @@ void usage(enum logcode F)
+@@ -323,7 +327,7 @@ void usage(enum logcode F)
}
enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
-- OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED,
-+ OPT_FILTER, OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED,
- OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
+- OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
++ OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT, OPT_MAX_SIZE,
-@@ -344,6 +348,7 @@ static struct poptOption long_options[]
- {"delete-excluded", 0, POPT_ARG_NONE, 0, OPT_DELETE_EXCLUDED, 0, 0 },
+ OPT_REFUSED_BASE = 9000};
+@@ -345,6 +349,7 @@ static struct poptOption long_options[]
+ {"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 },
{"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 },
{"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 },
+ {"filter", 'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 },
{"exclude", 0, POPT_ARG_STRING, 0, OPT_EXCLUDE, 0, 0 },
{"include", 0, POPT_ARG_STRING, 0, OPT_INCLUDE, 0, 0 },
{"exclude-from", 0, POPT_ARG_STRING, 0, OPT_EXCLUDE_FROM, 0, 0 },
-@@ -394,6 +399,7 @@ static struct poptOption long_options[]
+@@ -397,6 +402,7 @@ static struct poptOption long_options[]
{"ignore-errors", 0, POPT_ARG_NONE, &ignore_errors, 0, 0, 0 },
{"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 },
{"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 },
{0, 'P', POPT_ARG_NONE, 0, 'P', 0, 0 },
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 },
{"log-format", 0, POPT_ARG_STRING, &log_format, 0, 0, 0 },
-@@ -623,10 +629,15 @@ int parse_arguments(int *argc, const cha
- delete_mode = 1;
+@@ -618,10 +624,15 @@ int parse_arguments(int *argc, const cha
+ modify_window_set = 1;
break;
- case OPT_EXCLUDE:
case OPT_INCLUDE:
add_exclude(&exclude_list, poptGetOptArg(pc),
XFLG_DEF_INCLUDE);
-@@ -644,8 +655,8 @@ int parse_arguments(int *argc, const cha
+@@ -639,8 +650,8 @@ int parse_arguments(int *argc, const cha
goto options_rejected;
}
add_exclude_file(&exclude_list, arg, XFLG_FATAL_ERRORS
break;
case 'h':
-@@ -669,6 +680,19 @@ int parse_arguments(int *argc, const cha
+@@ -664,6 +675,19 @@ int parse_arguments(int *argc, const cha
am_sender = 1;
break;
};
struct exclude_list_struct {
---- orig/rsync.yo 2005-01-20 19:47:08
+--- orig/rsync.yo 2005-01-22 22:48:52
+++ rsync.yo 2005-01-21 19:56:38
@@ -361,6 +361,9 @@ verb(
-P equivalent to --partial --progress
case MSG_INFO:
case MSG_ERROR:
if (remaining >= sizeof line) {
---- orig/main.c 2005-01-17 23:11:45
+--- orig/main.c 2005-01-23 07:27:24
+++ main.c 2004-08-13 08:24:23
-@@ -42,6 +42,7 @@ extern int list_only;
+@@ -43,6 +43,7 @@ extern int list_only;
extern int local_server;
extern int log_got_error;
extern int module_id;
extern int orig_umask;
extern int copy_links;
extern int keep_dirlinks;
-@@ -648,6 +649,8 @@ void start_server(int f_in, int f_out, i
+@@ -649,6 +650,8 @@ void start_server(int f_in, int f_out, i
if (am_sender) {
keep_dirlinks = 0; /* Must be disabled on the sender. */
recv_exclude_list(f_in);
if (cvs_exclude)
-@@ -730,6 +733,9 @@ int client_run(int f_in, int f_out, pid_
+@@ -731,6 +734,9 @@ int client_run(int f_in, int f_out, pid_
exit_cleanup(status);
}
+ io_start_multiplex_out();
+
if (argc == 0)
- list_only = 1;
+ list_only |= 1;
---- orig/options.c 2005-01-20 23:05:34
-+++ options.c 2005-01-10 10:46:47
-@@ -89,8 +89,10 @@ int daemon_bwlimit = 0;
- int bwlimit = 0;
- size_t bwlimit_writemax = 0;
+--- orig/options.c 2005-01-23 01:45:43
++++ options.c 2005-01-23 07:30:51
+@@ -57,6 +57,7 @@ int delete_mode = 0;
+ int delete_before = 0;
int delete_after = 0;
+ int delete_excluded = 0;
+int delete_sent_files = 0;
+ int one_file_system = 0;
+ int protocol_version = PROTOCOL_VERSION;
+ int sparse_files = 0;
+@@ -92,6 +93,7 @@ int bwlimit = 0;
+ size_t bwlimit_writemax = 0;
int only_existing = 0;
int opt_ignore_existing = 0;
+int need_messages_from_generator = 0;
int max_delete = 0;
OFF_T max_size = 0;
int ignore_errors = 0;
-@@ -274,6 +276,7 @@ void usage(enum logcode F)
+@@ -276,6 +278,7 @@ void usage(enum logcode F)
rprintf(F," --delete delete files that don't exist on the sending side\n");
- rprintf(F," --delete-excluded also delete excluded files on the receiving side\n");
rprintf(F," --delete-after receiver deletes after transferring, not before\n");
+ rprintf(F," --delete-excluded also delete excluded files on the receiving side\n");
+ rprintf(F," --delete-sent-files updated/sent files are removed from sending side\n");
rprintf(F," --ignore-errors delete even if there are I/O errors\n");
+ rprintf(F," --force force deletion of directories even if not empty\n");
rprintf(F," --max-delete=NUM don't delete more than NUM files\n");
- rprintf(F," --max-size=SIZE don't transfer any file larger than SIZE\n");
-@@ -342,6 +345,7 @@ static struct poptOption long_options[]
- {"ignore-existing", 0, POPT_ARG_NONE, &opt_ignore_existing, 0, 0, 0 },
- {"delete-after", 0, POPT_ARG_NONE, 0, OPT_DELETE_AFTER, 0, 0 },
- {"delete-excluded", 0, POPT_ARG_NONE, 0, OPT_DELETE_EXCLUDED, 0, 0 },
+@@ -343,6 +346,7 @@ static struct poptOption long_options[]
+ {"delete", 0, POPT_ARG_NONE, &delete_before, 0, 0, 0 },
+ {"delete-after", 0, POPT_ARG_NONE, &delete_after, 0, 0, 0 },
+ {"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 },
+ {"delete-sent-files",0, POPT_ARG_NONE, &delete_sent_files, 0, 0, 0 },
{"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 },
{"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 },
{"exclude", 0, POPT_ARG_STRING, 0, OPT_EXCLUDE, 0, 0 },
@@ -858,6 +862,9 @@ int parse_arguments(int *argc, const cha
- if (relative_paths < 0)
- relative_paths = files_from? 1 : 0;
+ if (delete_excluded && !delete_mode)
+ delete_mode = delete_before = 1;
+ if (delete_sent_files)
+ need_messages_from_generator = 1;
*argv = poptGetArgs(pc);
*argc = count_args(*argv);
-@@ -1241,6 +1248,9 @@ void server_options(char **args,int *arg
+@@ -1244,6 +1251,9 @@ void server_options(char **args,int *arg
if (!implied_dirs && !am_sender)
args[ac++] = "--no-implied-dirs";
*argc = ac;
return;
---- orig/receiver.c 2005-01-21 00:35:26
+--- orig/receiver.c 2005-01-23 07:27:24
+++ receiver.c 2004-08-13 08:38:51
@@ -47,6 +47,7 @@ extern char *backup_dir;
extern char *backup_suffix;
MSG_DONE=5, /* current phase is done */
MSG_REDO=4, /* reprocess indicated flist index */
MSG_ERROR=FERROR, MSG_INFO=FINFO, MSG_LOG=FLOG, /* remote logging */
---- orig/rsync.yo 2005-01-20 19:47:08
-+++ rsync.yo 2004-07-03 20:17:10
+--- orig/rsync.yo 2005-01-22 22:48:52
++++ rsync.yo 2005-01-23 07:31:03
@@ -343,6 +343,7 @@ verb(
--delete delete files that don't exist on sender
- --delete-excluded also delete excluded files on receiver
--delete-after receiver deletes after transfer, not before
+ --delete-excluded also delete excluded files on receiver
+ --delete-sent-files updated/sent files are removed from sender
--ignore-errors delete even if there are I/O errors
+ --force force deletion of dirs even if not empty
--max-delete=NUM don't delete more than NUM files
- --max-size=SIZE don't transfer any file larger than SIZE
-@@ -695,6 +696,11 @@ One reason to use --delete-after is to a
- the transfer (while the receiving side is scanned for deletions) as this
- delay might cause the transfer to timeout.
+@@ -695,6 +696,11 @@ receiving side that are not on the sendi
+ delete any files on the receiving side that are excluded (see --exclude).
+ Implies --delete.
+dit(bf(--delete-sent-files)) This tells rsync to remove the source files
+on the sending side that are successfully transferred to the receiving