Previous solution for --no-whole-file would probably break when

connecting to old servers that don't have --no-whole-file.

Instead, we handle no_whole_file and whole_file separately, without
the magic -1 value.  We don't modify no_whole_file after
initialization.
This commit is contained in:
Martin Pool
2002-03-19 03:39:42 +00:00
parent ed521de525
commit bceec82f35
3 changed files with 42 additions and 19 deletions

View File

@@ -32,7 +32,6 @@ extern int preserve_devices;
extern int preserve_hard_links;
extern int update_only;
extern int opt_ignore_existing;
extern int whole_file;
extern int block_size;
extern int csum_length;
extern int ignore_times;
@@ -127,6 +126,39 @@ static void send_sums(struct sum_struct *s, int f_out)
}
}
/**
* Perhaps we want to just send an empty checksum set for this file,
* which will force the whole thing to be literally transferred.
*
* When do we do this? If the user's explicitly said they
* want the whole thing, or if { they haven't explicitly
* requested a delta, and it's local but not batch mode.}
*
* Whew. */
static BOOL disable_deltas_p(void)
{
extern int whole_file, no_whole_file;
extern int local_server;
extern int write_batch;
assert(whole_file == 0 || whole_file == 1);
/* OK, we don't explicitly handle both whole_file and
* no_whole_file; perhaps somebody will care to add an
* error. */
if (whole_file)
return True;
else if (no_whole_file)
return False;
else if (write_batch)
return False;
else
return local_server;
}
/*
generate a stream of signatures/checksums that describe a buffer
@@ -403,9 +435,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
return;
}
assert(whole_file == 0 || whole_file == 1);
/* We should have decided by now. */
if (whole_file) {
if (disable_deltas_p()) {
write_int(f_out,i);
send_sums(NULL,f_out);
return;

6
main.c
View File

@@ -716,12 +716,6 @@ static int start_client(int argc, char *argv[])
p = find_colon(argv[argc-1]);
if (!p) {
local_server = 1;
/*
* disable "rsync algorithm" when both sides local,
* except when creating a batch update
*/
if (!write_batch && whole_file == -1)
whole_file = 1;
} else if (p[1] == ':') {
*p = 0;
return start_socket_client(argv[argc-1], p+2, argc-1, argv);

View File

@@ -30,9 +30,11 @@ int make_backups = 0;
* because there it's no cheaper to read the whole basis file than to
* just rewrite it.
*
* -1 means "unspecified", i.e. depend on is_local; 0 means off; 1 means on.
* If both are 0, then look at whether we're local or remote and go by
* that.
**/
int whole_file = -1;
int whole_file = 0;
int no_whole_file = 0;
int copy_links = 0;
int preserve_links = 0;
@@ -310,7 +312,7 @@ static struct poptOption long_options[] = {
{"links", 'l', POPT_ARG_NONE, &preserve_links},
{"copy-links", 'L', POPT_ARG_NONE, &copy_links},
{"whole-file", 'W', POPT_ARG_NONE, &whole_file},
{"no-whole-file", 0, POPT_ARG_NONE, 0, OPT_NO_WHOLE_FILE},
{"no-whole-file", 0, POPT_ARG_NONE, &no_whole_file},
{"copy-unsafe-links", 0, POPT_ARG_NONE, &copy_unsafe_links},
{"perms", 'p', POPT_ARG_NONE, &preserve_perms},
{"owner", 'o', POPT_ARG_NONE, &preserve_uid},
@@ -474,10 +476,6 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
add_exclude_file(poptGetOptArg(pc), 1, 1);
break;
case OPT_NO_WHOLE_FILE:
whole_file = 0;
break;
case OPT_NO_BLOCKING_IO:
blocking_io = 0;
break;
@@ -601,8 +599,6 @@ void server_options(char **args,int *argc)
int i, x;
if (whole_file == -1)
whole_file = 0;
if (blocking_io == -1)
blocking_io = 0;
@@ -631,6 +627,9 @@ void server_options(char **args,int *argc)
assert(whole_file == 0 || whole_file == -1);
if (whole_file)
argstr[x++] = 'W';
/* We don't need to send --no-whole-file, because it's the
* default for remote transfers, and in any case old versions
* of rsync will not understand it. */
if (preserve_hard_links)
argstr[x++] = 'H';