Commit ef20efcb authored by Wayne Davison's avatar Wayne Davison

Made itemize() output the fnamecmp_type and the fuzzy name based on

the new ITEM_BASIS_TYPE_FOLLOWS and ITEM_XNAME_FOLLOWS flags.  Got
rid of the name-pipe to the receiver.
parent c70e07d9
...@@ -308,7 +308,7 @@ static int unchanged_attrs(struct file_struct *file, STRUCT_STAT *st) ...@@ -308,7 +308,7 @@ static int unchanged_attrs(struct file_struct *file, STRUCT_STAT *st)
void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st, void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st,
int32 iflags, char *hlink) int32 iflags, uchar fnamecmp_type, char *xname)
{ {
if (statret == 0) { if (statret == 0) {
if (S_ISREG(file->mode) && file->length != st->st_size) if (S_ISREG(file->mode) && file->length != st->st_size)
...@@ -329,23 +329,22 @@ void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st, ...@@ -329,23 +329,22 @@ void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st,
&& st->st_gid != file->gid) && st->st_gid != file->gid)
iflags |= ITEM_REPORT_GROUP; iflags |= ITEM_REPORT_GROUP;
} }
} else { } else
iflags |= ITEM_IS_NEW; iflags |= ITEM_IS_NEW;
if (!(iflags & (ITEM_HARD_LINKED|ITEM_LOCAL_CHANGE)))
iflags |= ITEM_TRANSFER;
}
iflags &= 0xffff; iflags &= 0xffff;
if ((iflags & SIGNIFICANT_ITEM_FLAGS || verbose > 1 if ((iflags & SIGNIFICANT_ITEM_FLAGS || verbose > 1
|| (hlink && *hlink)) && !read_batch) { || (xname && *xname)) && !read_batch) {
if (protocol_version >= 29) { if (protocol_version >= 29) {
if (ndx >= 0) if (ndx >= 0)
write_int(sock_f_out, ndx); write_int(sock_f_out, ndx);
write_shortint(sock_f_out, iflags); write_shortint(sock_f_out, iflags);
if (hlink) if (iflags & ITEM_BASIS_TYPE_FOLLOWS)
write_vstring(sock_f_out, hlink, strlen(hlink)); write_byte(sock_f_out, fnamecmp_type);
if (iflags & ITEM_XNAME_FOLLOWS)
write_vstring(sock_f_out, xname, strlen(xname));
} else if (ndx >= 0) } else if (ndx >= 0)
log_item(file, &stats, iflags, hlink); log_item(file, &stats, iflags, xname);
} }
} }
...@@ -582,7 +581,7 @@ static int phase = 0; ...@@ -582,7 +581,7 @@ static int phase = 0;
* modification-time repair. */ * modification-time repair. */
static void recv_generator(char *fname, struct file_struct *file, int ndx, static void recv_generator(char *fname, struct file_struct *file, int ndx,
int itemizing, int maybe_PERMS_REPORT, int itemizing, int maybe_PERMS_REPORT,
enum logcode code, int f_out, int f_out_name) enum logcode code, int f_out)
{ {
static int missing_below = -1, excluded_below = -1; static int missing_below = -1, excluded_below = -1;
static char *fuzzy_dirname = NULL; static char *fuzzy_dirname = NULL;
...@@ -697,7 +696,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, ...@@ -697,7 +696,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
} }
if (itemizing && f_out != -1) { if (itemizing && f_out != -1) {
itemize(file, ndx, statret, &st, itemize(file, ndx, statret, &st,
statret ? ITEM_LOCAL_CHANGE : 0, NULL); statret ? ITEM_LOCAL_CHANGE : 0, 0, NULL);
} }
if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) { if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) {
if (!relative_paths || errno != ENOENT if (!relative_paths || errno != ENOENT
...@@ -749,7 +748,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, ...@@ -749,7 +748,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
if (strcmp(lnk, file->u.link) == 0) { if (strcmp(lnk, file->u.link) == 0) {
if (itemizing) { if (itemizing) {
itemize(file, ndx, 0, &st, 0, itemize(file, ndx, 0, &st, 0,
NULL); 0, NULL);
} }
set_perms(fname, file, &st, set_perms(fname, file, &st,
maybe_PERMS_REPORT); maybe_PERMS_REPORT);
...@@ -772,7 +771,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, ...@@ -772,7 +771,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
set_perms(fname,file,NULL,0); set_perms(fname,file,NULL,0);
if (itemizing) { if (itemizing) {
itemize(file, ndx, statret, &st, itemize(file, ndx, statret, &st,
ITEM_LOCAL_CHANGE, NULL); ITEM_LOCAL_CHANGE, 0, NULL);
} }
if (code && verbose) { if (code && verbose) {
rprintf(code, "%s -> %s\n", safe_fname(fname), rprintf(code, "%s -> %s\n", safe_fname(fname),
...@@ -807,7 +806,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, ...@@ -807,7 +806,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
set_perms(fname,file,NULL,0); set_perms(fname,file,NULL,0);
if (itemizing) { if (itemizing) {
itemize(file, ndx, statret, &st, itemize(file, ndx, statret, &st,
ITEM_LOCAL_CHANGE, NULL); ITEM_LOCAL_CHANGE, 0, NULL);
} }
if (code && verbose) { if (code && verbose) {
rprintf(code, "%s\n", rprintf(code, "%s\n",
...@@ -816,7 +815,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, ...@@ -816,7 +815,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
} }
} else { } else {
if (itemizing) if (itemizing)
itemize(file, ndx, statret, &st, 0, NULL); itemize(file, ndx, statret, &st, 0, 0, NULL);
set_perms(fname, file, &st, maybe_PERMS_REPORT); set_perms(fname, file, &st, maybe_PERMS_REPORT);
} }
return; return;
...@@ -964,7 +963,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, ...@@ -964,7 +963,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
else if (unchanged_file(fnamecmp, file, &st)) { else if (unchanged_file(fnamecmp, file, &st)) {
if (fnamecmp_type == FNAMECMP_FNAME) { if (fnamecmp_type == FNAMECMP_FNAME) {
if (itemizing) if (itemizing)
itemize(file, ndx, statret, &st, 0, NULL); itemize(file, ndx, statret, &st, 0, 0, NULL);
set_perms(fname, file, &st, maybe_PERMS_REPORT); set_perms(fname, file, &st, maybe_PERMS_REPORT);
if (preserve_hard_links && file->link_u.links) if (preserve_hard_links && file->link_u.links)
hard_link_cluster(file, ndx, itemizing, code); hard_link_cluster(file, ndx, itemizing, code);
...@@ -973,7 +972,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, ...@@ -973,7 +972,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
/* Only --compare-dest gets here. */ /* Only --compare-dest gets here. */
if (unchanged_attrs(file, &st)) { if (unchanged_attrs(file, &st)) {
itemize(file, ndx, statret, &st, itemize(file, ndx, statret, &st,
ITEM_NO_DEST_AND_NO_UPDATE, NULL); ITEM_NO_DEST_AND_NO_UPDATE, 0, NULL);
return; return;
} }
} }
...@@ -1009,7 +1008,7 @@ prepare_to_open: ...@@ -1009,7 +1008,7 @@ prepare_to_open:
goto notify_others; goto notify_others;
} }
if (inplace && make_backups) { if (inplace && make_backups && fnamecmp_type == FNAMECMP_FNAME) {
if (!(backupptr = get_backup_name(fname))) { if (!(backupptr = get_backup_name(fname))) {
close(fd); close(fd);
return; return;
...@@ -1051,15 +1050,11 @@ notify_others: ...@@ -1051,15 +1050,11 @@ notify_others:
if (always_checksum) if (always_checksum)
iflags |= ITEM_REPORT_CHECKSUM; iflags |= ITEM_REPORT_CHECKSUM;
if (fnamecmp_type != FNAMECMP_FNAME) if (fnamecmp_type != FNAMECMP_FNAME)
iflags |= ITEM_USING_ALT_BASIS; iflags |= ITEM_BASIS_TYPE_FOLLOWS;
itemize(file, -1, statret, &st, iflags, NULL); if (fnamecmp_type == FNAMECMP_FUZZY)
} iflags |= ITEM_XNAME_FOLLOWS;
if (f_out_name >= 0) { itemize(file, -1, statret, &st, iflags, fnamecmp_type,
write_byte(f_out_name, fnamecmp_type); fuzzy_file ? fuzzy_file->basename : NULL);
if (fnamecmp_type == FNAMECMP_FUZZY) {
write_vstring(f_out_name, fuzzy_file->basename,
strlen(fuzzy_file->basename));
}
} }
if (dry_run) { if (dry_run) {
...@@ -1091,8 +1086,7 @@ notify_others: ...@@ -1091,8 +1086,7 @@ notify_others:
} }
void generate_files(int f_out, struct file_list *flist, char *local_name, void generate_files(int f_out, struct file_list *flist, char *local_name)
int f_out_name)
{ {
int i, lull_mod; int i, lull_mod;
char fbuf[MAXPATHLEN]; char fbuf[MAXPATHLEN];
...@@ -1152,7 +1146,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name, ...@@ -1152,7 +1146,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name,
recv_generator(local_name ? local_name : f_name_to(file, fbuf), recv_generator(local_name ? local_name : f_name_to(file, fbuf),
file, i, itemizing, maybe_PERMS_REPORT, code, file, i, itemizing, maybe_PERMS_REPORT, code,
f_out, f_out_name); f_out);
/* We need to ensure that any dirs we create have writeable /* We need to ensure that any dirs we create have writeable
* permissions during the time we are putting files within * permissions during the time we are putting files within
...@@ -1174,7 +1168,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name, ...@@ -1174,7 +1168,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name,
if (allowed_lull && !(i % lull_mod)) if (allowed_lull && !(i % lull_mod))
maybe_send_keepalive(); maybe_send_keepalive();
} }
recv_generator(NULL, NULL, 0, 0, 0, code, -1, -1); recv_generator(NULL, NULL, 0, 0, 0, code, -1);
if (delete_during) if (delete_during)
delete_in_dir(NULL, NULL, NULL); delete_in_dir(NULL, NULL, NULL);
...@@ -1200,7 +1194,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name, ...@@ -1200,7 +1194,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name,
struct file_struct *file = flist->files[i]; struct file_struct *file = flist->files[i];
recv_generator(local_name ? local_name : f_name_to(file, fbuf), recv_generator(local_name ? local_name : f_name_to(file, fbuf),
file, i, itemizing, maybe_PERMS_REPORT, code, file, i, itemizing, maybe_PERMS_REPORT, code,
f_out, f_out_name); f_out);
} }
phase++; phase++;
...@@ -1232,12 +1226,12 @@ void generate_files(int f_out, struct file_list *flist, char *local_name, ...@@ -1232,12 +1226,12 @@ void generate_files(int f_out, struct file_list *flist, char *local_name,
continue; continue;
recv_generator(local_name ? local_name : f_name(file), recv_generator(local_name ? local_name : f_name(file),
file, i, itemizing, maybe_PERMS_REPORT, file, i, itemizing, maybe_PERMS_REPORT,
code, -1, -1); code, -1);
if (allowed_lull && !(j++ % lull_mod)) if (allowed_lull && !(j++ % lull_mod))
maybe_send_keepalive(); maybe_send_keepalive();
} }
} }
recv_generator(NULL, NULL, 0, 0, 0, code, -1, -1); recv_generator(NULL, NULL, 0, 0, 0, code, -1);
if (max_delete > 0 && deletion_count > max_delete) { if (max_delete > 0 && deletion_count > max_delete) {
rprintf(FINFO, rprintf(FINFO,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment