Delay the renaming of all the temp files until the end of the transfer.
---- orig/options.c 2005-01-23 01:45:43
+--- orig/options.c 2005-01-24 01:43:10
+++ options.c 2005-01-23 07:27:59
-@@ -99,6 +99,7 @@ int modify_window = 0;
+@@ -101,6 +101,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. */
-@@ -273,6 +274,7 @@ void usage(enum logcode F)
+@@ -276,6 +277,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," --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[]
+ rprintf(F," --delete-before receiver deletes before transfer, not during\n");
+ rprintf(F," --delete-after receiver deletes after transfer, not during\n");
+@@ -401,6 +403,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 },
-@@ -948,11 +951,15 @@ int parse_arguments(int *argc, const cha
+@@ -955,11 +958,15 @@ int parse_arguments(int *argc, const cha
bwlimit_writemax = 512;
}
return 0;
}
keep_partial = 0;
-@@ -1187,6 +1194,8 @@ void server_options(char **args,int *arg
+@@ -1198,6 +1205,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-23 07:27:24
+--- orig/receiver.c 2005-01-24 01:43:10
+++ receiver.c 2005-01-10 10:16:54
-@@ -53,6 +53,7 @@ extern int orig_umask;
+@@ -48,6 +48,7 @@ extern int orig_umask;
extern int keep_partial;
extern int checksum_seed;
extern int inplace;
extern struct exclude_list_struct server_exclude_list;
-@@ -324,6 +325,7 @@ int recv_files(int f_in, struct file_lis
+@@ -272,6 +273,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;
-@@ -337,6 +339,12 @@ int recv_files(int f_in, struct file_lis
+@@ -285,6 +287,12 @@ int recv_files(int f_in, struct file_lis
flist->hlink_pool = NULL;
}
while (1) {
cleanup_disable();
-@@ -551,7 +559,7 @@ int recv_files(int f_in, struct file_lis
+@@ -499,7 +507,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);
-@@ -561,6 +569,8 @@ int recv_files(int f_in, struct file_lis
+@@ -509,6 +517,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);
-@@ -600,6 +610,33 @@ int recv_files(int f_in, struct file_lis
+@@ -548,6 +558,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-22 22:48:52
+--- orig/rsync.yo 2005-01-24 01:43:10
+++ rsync.yo 2005-01-23 07:28:13
-@@ -340,6 +340,7 @@ verb(
+@@ -342,6 +342,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
--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
+ --delete-before receiver deletes before xfer, not during
+ --delete-after receiver deletes after transfer, not during
+@@ -545,9 +546,9 @@ or appended data, and also on systems th
bound.
The option implies --partial (since an interrupted transfer does not delete
WARNING: The file's data will be in an inconsistent state during the
transfer (and possibly afterward if the transfer gets interrupted), so you
-@@ -978,6 +979,17 @@ environment and then just use the -P opt
+@@ -1003,6 +1004,17 @@ environment and then just use the -P opt
does not look for this environment value is when --inplace was also
specified (since --inplace conflicts with --partial-dir).
#define RERR_SIGNAL 20 /* status returned when sent SIGUSR1, SIGINT */
#define RERR_WAITCHILD 21 /* some error returned by waitpid() */
---- orig/flist.c 2005-01-24 00:18:21
+--- orig/flist.c 2005-01-24 01:43:09
+++ flist.c 2005-01-21 19:10:03
-@@ -64,6 +64,7 @@ extern int sanitize_paths;
- extern int delete_excluded;
+@@ -70,6 +70,7 @@ extern int delete_excluded;
+ extern int max_delete;
extern int orig_umask;
extern int list_only;
+extern char *fname_convert_cmd;
extern struct exclude_list_struct exclude_list;
extern struct exclude_list_struct server_exclude_list;
-@@ -359,7 +360,10 @@ void send_file_entry(struct file_struct
+@@ -365,7 +366,10 @@ void send_file_entry(struct file_struct
io_write_phase = "send_file_entry";
flags = base_flags;
-@@ -572,6 +576,9 @@ void receive_file_entry(struct file_stru
+@@ -581,6 +585,9 @@ void receive_file_entry(struct file_stru
strlcpy(lastname, thisname, MAXPATHLEN);
clean_fname(thisname, 0);
if (sanitize_paths)
-@@ -1087,6 +1094,9 @@ struct file_list *send_file_list(int f,
+@@ -1110,6 +1117,9 @@ struct file_list *send_file_list(int f,
start_write = stats.total_written;
flist = flist_new(f == -1 ? WITHOUT_HLINK : WITH_HLINK,
"send_file_list");
-@@ -1262,6 +1272,9 @@ struct file_list *send_file_list(int f,
+@@ -1287,6 +1297,9 @@ struct file_list *send_file_list(int f,
stats.num_files = flist->count;
}
if (verbose > 3)
output_flist(flist, f < 0 ? "delete" : who_am_i());
-@@ -1283,6 +1296,9 @@ struct file_list *recv_file_list(int f)
+@@ -1308,6 +1321,9 @@ struct file_list *recv_file_list(int f)
start_read = stats.total_read;
flist = flist_new(WITH_HLINK, "recv_file_list");
received_flist = flist;
-@@ -1336,6 +1352,9 @@ struct file_list *recv_file_list(int f)
+@@ -1361,6 +1377,9 @@ struct file_list *recv_file_list(int f)
io_error |= read_int(f);
}
+ if (verbose > 2)
+ rprintf(FINFO, "Converted filename: %s -> %s\n", src, dest);
+}
---- orig/generator.c 2005-01-20 23:05:34
+--- orig/generator.c 2005-01-24 01:43:09
+++ generator.c 2004-07-03 20:18:02
-@@ -232,6 +232,12 @@ static void generate_and_send_sums(int f
+@@ -233,6 +233,12 @@ static void generate_and_send_sums(int f
*
* @note This comment was added later by mbp who was trying to work it
* out. It might be wrong.
+ * sender (unconverted). To solve the above, move all progress
+ * reporting to the sender.
*/
- static void recv_generator(char *fname, struct file_struct *file, int i,
- int f_out, int f_out_name)
+ static void recv_generator(char *fname, struct file_list *flist,
+ struct file_struct *file, int i,
--- orig/log.c 2004-09-07 19:54:51
+++ log.c 2004-07-03 20:18:02
@@ -57,6 +57,7 @@ struct {
{ RERR_SIGNAL , "received SIGUSR1 or SIGINT" },
{ RERR_WAITCHILD , "some error returned by waitpid()" },
{ RERR_MALLOC , "error allocating core memory buffers" },
---- orig/main.c 2005-01-23 07:27:24
+--- orig/main.c 2005-01-24 01:43:10
+++ main.c 2004-07-22 00:31:47
@@ -335,7 +335,7 @@ static pid_t do_cmd(char *cmd, char *mac
whole_file = 1;
if (dir)
free(dir);
---- orig/options.c 2005-01-24 00:18:21
+--- orig/options.c 2005-01-24 01:43:10
+++ options.c 2005-01-15 21:28:07
-@@ -127,6 +127,7 @@ char *basis_dir[MAX_BASIS_DIRS+1];
+@@ -129,6 +129,7 @@ char *basis_dir[MAX_BASIS_DIRS+1];
char *config_file = NULL;
char *shell_cmd = NULL;
char *log_format = NULL;
char *password_file = NULL;
char *rsync_path = RSYNC_PATH;
char *backup_dir = NULL;
-@@ -292,6 +293,7 @@ void usage(enum logcode F)
+@@ -296,6 +297,7 @@ void usage(enum logcode F)
rprintf(F," --copy-dest=DIR ... and include copies of unchanged files\n");
rprintf(F," --link-dest=DIR hardlink to files in DIR when unchanged\n");
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");
-@@ -389,6 +391,7 @@ static struct poptOption long_options[]
+@@ -395,6 +397,7 @@ static struct poptOption long_options[]
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
{"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
This patch from Sami Farin lets you specify --fsync if you want fsync()
to be called on every file we write.
---- orig/options.c 2005-01-17 23:11:45
+--- orig/options.c 2005-01-24 01:43:10
+++ options.c 2004-11-27 18:10:44
@@ -38,6 +38,7 @@ int make_backups = 0;
**/
int archive_mode = 0;
int keep_dirlinks = 0;
int copy_links = 0;
-@@ -247,6 +248,7 @@ void usage(enum logcode F)
+@@ -251,6 +252,7 @@ void usage(enum logcode F)
rprintf(F," -b, --backup make backups (see --suffix & --backup-dir)\n");
rprintf(F," --backup-dir make backups into this directory\n");
rprintf(F," --suffix=SUFFIX backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
+ rprintf(F," --fsync fsync every written file\n");
rprintf(F," -u, --update update only (don't overwrite newer files)\n");
rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n");
- rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n");
-@@ -350,6 +352,7 @@ static struct poptOption long_options[]
+ rprintf(F," -d, --dirs transfer directories without recursing\n");
+@@ -358,6 +360,7 @@ static struct poptOption long_options[]
{"safe-links", 0, POPT_ARG_NONE, &safe_symlinks, 0, 0, 0 },
{"help", 'h', POPT_ARG_NONE, 0, 'h', 0, 0 },
{"backup", 'b', POPT_ARG_NONE, &make_backups, 0, 0, 0 },
{"dry-run", 'n', POPT_ARG_NONE, &dry_run, 0, 0, 0 },
{"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 },
{"cvs-exclude", 'C', POPT_ARG_NONE, &cvs_exclude, 0, 0, 0 },
-@@ -1208,6 +1211,9 @@ void server_options(char **args,int *arg
+@@ -1227,6 +1230,9 @@ void server_options(char **args,int *arg
args[ac++] = tmpdir;
}
if (basis_dir[0] && am_sender) {
/* the server only needs this option if it is not the sender,
* and it may be an older version that doesn't know this
---- orig/receiver.c 2005-01-17 23:11:45
+--- orig/receiver.c 2005-01-24 01:43:10
+++ receiver.c 2004-07-16 20:13:31
-@@ -37,6 +37,7 @@ extern int preserve_hard_links;
+@@ -35,6 +35,7 @@ extern int keep_dirlinks;
+ extern int preserve_hard_links;
extern int preserve_perms;
- extern int cvs_exclude;
extern int io_error;
+extern int do_fsync;
extern char *tmpdir;
extern char *partial_dir;
extern char *basis_dir[];
-@@ -310,6 +311,12 @@ static int receive_data(int f_in, char *
+@@ -237,6 +238,12 @@ static int receive_data(int f_in, char *
exit_cleanup(RERR_FILEIO);
}
char *partial_dir;
struct exclude_list_struct server_exclude_list;
---- orig/util.c 2004-09-07 21:45:30
+--- orig/util.c 2005-01-20 23:05:34
+++ util.c 2004-07-03 20:18:13
@@ -33,6 +33,7 @@ extern int module_id;
extern int modify_window;
case MSG_INFO:
case MSG_ERROR:
if (remaining >= sizeof line) {
---- orig/main.c 2005-01-23 07:27:24
+--- orig/main.c 2005-01-24 01:43:10
+++ main.c 2004-08-13 08:24:23
@@ -43,6 +43,7 @@ extern int list_only;
extern int local_server;
if (argc == 0)
list_only |= 1;
---- orig/options.c 2005-01-23 01:45:43
+--- orig/options.c 2005-01-24 01:43:10
+++ options.c 2005-01-23 07:30:51
-@@ -57,6 +57,7 @@ int delete_mode = 0;
+@@ -59,6 +59,7 @@ int delete_during = 0;
int delete_before = 0;
int delete_after = 0;
int delete_excluded = 0;
int one_file_system = 0;
int protocol_version = PROTOCOL_VERSION;
int sparse_files = 0;
-@@ -92,6 +93,7 @@ int bwlimit = 0;
+@@ -94,6 +95,7 @@ int bwlimit = 0;
size_t bwlimit_writemax = 0;
int only_existing = 0;
int opt_ignore_existing = 0;
int max_delete = 0;
OFF_T max_size = 0;
int ignore_errors = 0;
-@@ -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-after receiver deletes after transferring, not before\n");
+@@ -280,6 +282,7 @@ void usage(enum logcode F)
+ rprintf(F," --delete-before receiver deletes before transfer, not during\n");
+ rprintf(F," --delete-after receiver deletes after transfer, not during\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");
-@@ -343,6 +346,7 @@ static struct poptOption long_options[]
- {"delete", 0, POPT_ARG_NONE, &delete_before, 0, 0, 0 },
+@@ -349,6 +352,7 @@ static struct poptOption long_options[]
+ {"delete-before", 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
+@@ -865,6 +869,9 @@ int parse_arguments(int *argc, const cha
if (delete_excluded && !delete_mode)
- delete_mode = delete_before = 1;
+ delete_mode = delete_during = 1;
+ if (delete_sent_files)
+ need_messages_from_generator = 1;
*argv = poptGetArgs(pc);
*argc = count_args(*argv);
-@@ -1244,6 +1251,9 @@ void server_options(char **args,int *arg
+@@ -1255,6 +1262,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-23 07:27:24
+--- orig/receiver.c 2005-01-24 01:43:10
+++ receiver.c 2004-08-13 08:38:51
-@@ -47,6 +47,7 @@ extern char *backup_dir;
- extern char *backup_suffix;
- extern int backup_suffix_len;
+@@ -42,6 +42,7 @@ extern int basis_dir_cnt;
+ extern int make_backups;
+ extern int do_progress;
extern int cleanup_got_literal;
+extern int delete_sent_files;
extern int module_id;
extern int ignore_errors;
extern int orig_umask;
-@@ -322,7 +323,7 @@ int recv_files(int f_in, struct file_lis
+@@ -270,7 +271,7 @@ int recv_files(int f_in, struct file_lis
char *fname, fbuf[MAXPATHLEN];
char template[MAXPATHLEN];
char fnametmp[MAXPATHLEN];
char fnamecmpbuf[MAXPATHLEN];
struct file_struct *file;
struct stats initial_stats;
-@@ -568,7 +569,12 @@ int recv_files(int f_in, struct file_lis
+@@ -516,7 +517,12 @@ int recv_files(int f_in, struct file_lis
cleanup_disable();
int msgtype = csum_length == SUM_LENGTH || read_batch ?
FERROR : FINFO;
if (msgtype == FERROR || verbose) {
-@@ -592,9 +598,8 @@ int recv_files(int f_in, struct file_lis
+@@ -540,9 +546,8 @@ int recv_files(int f_in, struct file_lis
keptstr, redostr);
}
if (csum_length != SUM_LENGTH) {
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-22 22:48:52
+--- orig/rsync.yo 2005-01-24 01:43:10
+++ rsync.yo 2005-01-23 07:31:03
-@@ -343,6 +343,7 @@ verb(
- --delete delete files that don't exist on sender
- --delete-after receiver deletes after transfer, not before
+@@ -346,6 +346,7 @@ verb(
+ --delete-before receiver deletes before xfer, not during
+ --delete-after receiver deletes after transfer, not during
--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
-@@ -695,6 +696,11 @@ receiving side that are not on the sendi
+@@ -720,6 +721,11 @@ receiving side that are not on the sendi
delete any files on the receiving side that are excluded (see --exclude).
Implies --delete.