X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/4c9d5fef07041b2b210a9e7c1cfbf883f848d2f1..c5b6e57a136d5bdc1eff9ef11e69c7093065920e:/flist.c diff --git a/flist.c b/flist.c index 66e373f0..db1cd901 100644 --- a/flist.c +++ b/flist.c @@ -343,7 +343,7 @@ int push_flist_dir(const char *dir, int len) return 1; } -static void send_file_entry(struct file_struct *file, int f, int ndx) +static void send_file_entry(int f, struct file_struct *file, int ndx) { static time_t modtime; static mode_t mode; @@ -548,6 +548,9 @@ static void send_file_entry(struct file_struct *file, int f, int ndx) the_end: strlcpy(lastname, fname, MAXPATHLEN); + + if (S_ISREG(mode) || S_ISLNK(mode)) + stats.total_size += F_LENGTH(file); } static struct file_struct *recv_file_entry(struct file_list *flist, @@ -755,9 +758,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist, } file->mode = mode; if (preserve_uid) - F_UID(file) = uid; + F_OWNER(file) = uid; if (preserve_gid) - F_GID(file) = gid; + F_GROUP(file) = gid; if (basename != thisname) { file->dirname = lastdir; @@ -849,6 +852,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist, read_buf(f, bp, checksum_len); } + if (S_ISREG(mode) || S_ISLNK(mode)) + stats.total_size += file_length; + return file; } @@ -1052,9 +1058,9 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, } file->mode = st.st_mode; if (preserve_uid) - F_UID(file) = st.st_uid; + F_OWNER(file) = st.st_uid; if (preserve_gid) - F_GID(file) = st.st_gid; + F_GROUP(file) = st.st_gid; if (basename != thisname) file->dirname = lastdir; @@ -1083,16 +1089,13 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, file->len32 = 0; file->mode = st2.st_mode; if (preserve_uid) - F_UID(file) = st2.st_uid; + F_OWNER(file) = st2.st_uid; if (preserve_gid) - F_GID(file) = st2.st_gid; + F_GROUP(file) = st2.st_gid; } else file->mode = save_mode; } - if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) - stats.total_size += st.st_size; - if (basename_len == 0+1) return NULL; @@ -1115,7 +1118,7 @@ void unmake_file(struct file_struct *file) free(REQ_EXTRA(file, extra_cnt)); } -static struct file_struct *send_file_name(struct file_list *flist, +static struct file_struct *send_file_name(int f, struct file_list *flist, char *fname, STRUCT_STAT *stp, int flags, int filter_flags) { @@ -1132,6 +1135,8 @@ static struct file_struct *send_file_name(struct file_list *flist, flist_expand(flist); flist->files[flist->count++] = file; + if (f >= 0) + send_file_entry(f, file, flist->count - 1); return file; } @@ -1215,7 +1220,6 @@ static void send_directory(int f, struct file_list *flist, int parent_ndx, int divert_dirs = (flags & FLAG_DIVERT_DIRS) != 0; int start = divert_dirs ? dir_flist->count : flist->count; int filter_flags = f == -2 ? SERVER_FILTERS : ALL_FILTERS; - struct file_struct *file; assert(flist != NULL); @@ -1244,9 +1248,7 @@ static void send_directory(int f, struct file_list *flist, int parent_ndx, continue; } - file = send_file_name(flist, fbuf, NULL, flags, filter_flags); - if (file && f >= 0) - send_file_entry(file, f, flist->count - 1); + send_file_name(f, flist, fbuf, NULL, flags, filter_flags); } fbuf[len] = '\0'; @@ -1301,7 +1303,7 @@ void send_extra_file_list(int f, int at_least) flist = flist_new(0, "send_extra_file_list"); start_write = stats.total_written; - write_int(f, NDX_FLIST_OFFSET - send_dir_ndx); + write_ndx(f, NDX_FLIST_OFFSET - send_dir_ndx); change_local_filter_dir(fbuf, dlen, send_dir_depth); send_directory(f, flist, send_dir_ndx, fbuf, dlen, FLAG_DIVERT_DIRS | FLAG_XFER_DIR); write_byte(f, 0); @@ -1320,7 +1322,7 @@ void send_extra_file_list(int f, int at_least) } else { while (DIR_NEXT_SIBLING(dp) < 0) { if ((send_dir_ndx = DIR_PARENT(dp)) < 0) { - write_int(f, NDX_FLIST_EOF); + write_ndx(f, NDX_FLIST_EOF); flist_eof = 1; change_local_filter_dir(NULL, 0, 0); goto finish; @@ -1346,7 +1348,6 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) char lastpath[MAXPATHLEN] = ""; struct file_list *flist; struct timeval start_tv, end_tv; - struct file_struct *file; int64 start_write; int use_ff_fd = 0; int flags, disable_buffering; @@ -1354,6 +1355,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) rprintf(FLOG, "building file list\n"); if (show_filelist_p()) start_filelist_progress("building file list"); + else if (incremental && verbose && !am_server) + rprintf(FCLIENT, "sending incremental file list\n"); start_write = stats.total_written; gettimeofday(&start_tv, NULL); @@ -1545,9 +1548,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) xfer_dirs = 1; while ((slash = strchr(slash+1, '/')) != 0) { *slash = '\0'; - file = send_file_name(flist, fbuf, NULL, dir_flags, ALL_FILTERS); - if (file) - send_file_entry(file, f, flist->count - 1); + send_file_name(f, flist, fbuf, NULL, + dir_flags, ALL_FILTERS); *slash = '/'; } copy_links = save_copy_links; @@ -1562,20 +1564,16 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) filesystem_dev = st.st_dev; if (recurse || (xfer_dirs && is_dot_dir)) { + struct file_struct *file; int top_flags = FLAG_TOP_DIR | FLAG_XFER_DIR | (is_dot_dir ? 0 : flags) | (incremental ? FLAG_DIVERT_DIRS : 0); - file = send_file_name(flist, fbuf, &st, top_flags, ALL_FILTERS); - if (file) { - send_file_entry(file, f, flist->count - 1); - if (!incremental) - send_if_directory(f, flist, file, fbuf, len, flags); - } - } else { - file = send_file_name(flist, fbuf, &st, flags, ALL_FILTERS); - if (file) - send_file_entry(file, f, flist->count - 1); - } + file = send_file_name(f, flist, fbuf, &st, + top_flags, ALL_FILTERS); + if (file && !incremental) + send_if_directory(f, flist, file, fbuf, len, flags); + } else + send_file_name(f, flist, fbuf, &st, flags, ALL_FILTERS); } gettimeofday(&end_tv, NULL); @@ -1635,7 +1633,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) * was just 1 item in the first file-list, send 1 more * file-list to check if this is a 1-file xfer. */ if (send_dir_ndx < 0) - write_int(f, NDX_DONE); + write_ndx(f, NDX_DONE); else send_extra_file_list(f, 1); } @@ -1650,10 +1648,12 @@ struct file_list *recv_file_list(int f) int dstart, flags; int64 start_read; - if (f >= 0 && !incremental) + if (!first_flist) rprintf(FLOG, "receiving file list\n"); if (show_filelist_p()) start_filelist_progress("receiving file list"); + else if (incremental && verbose && !am_server && !first_flist) + rprintf(FCLIENT, "receiving incremental file list\n"); start_read = stats.total_read; @@ -1682,9 +1682,6 @@ struct file_list *recv_file_list(int f) flags |= read_byte(f) << 8; file = recv_file_entry(flist, flags, f); - if (S_ISREG(file->mode) || S_ISLNK(file->mode)) - stats.total_size += F_LENGTH(file); - if (incremental && S_ISDIR(file->mode)) { flist_expand(dir_flist); dir_flist->files[dir_flist->count++] = file; @@ -1746,7 +1743,7 @@ struct file_list *recv_file_list(int f) void recv_additional_file_list(int f) { struct file_list *flist; - int ndx = read_int(f); + int ndx = read_ndx(f); if (ndx == NDX_DONE) { flist_eof = 1; change_local_filter_dir(NULL, 0, 0); @@ -2038,7 +2035,7 @@ static void clean_flist(struct file_list *flist, int strip_root, int no_dups) } } } - /* Dump empty all remaining empty dirs. */ + /* Dump all remaining empty dirs. */ while (1) { struct file_struct *fp = flist->files[prev_i]; if (F_DEPTH(fp) >= 0)