Skip to content

Commit

Permalink
Don't force nanoseconds if a file wasn't transferred or checksummed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne Davison committed Jan 15, 2018
1 parent c4a3f55 commit 0f8e9e2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ int make_backup(const char *fname, BOOL prefer_rename)

save_preserve_xattrs = preserve_xattrs;
preserve_xattrs = 0;
set_file_attrs(buf, file, NULL, fname, 0);
set_file_attrs(buf, file, NULL, fname, ATTRS_SET_NANO);
preserve_xattrs = save_preserve_xattrs;

unmake_file(file);
Expand Down
5 changes: 4 additions & 1 deletion generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ extern struct file_list *cur_flist, *first_flist, *dir_flist;
extern filter_rule_list filter_list, daemon_filter_list;

int maybe_ATTRS_REPORT = 0;
int maybe_ATTRS_SET_NANO = 0;

static dev_t dev_zero;
static int deldelay_size = 0, deldelay_cnt = 0;
Expand Down Expand Up @@ -1214,6 +1215,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
return;
}

maybe_ATTRS_SET_NANO = always_checksum ? ATTRS_SET_NANO : 0;

if (skip_dir) {
if (is_below(file, skip_dir)) {
if (is_dir)
Expand Down Expand Up @@ -1762,7 +1765,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
do_unlink(partialptr);
handle_partial_dir(partialptr, PDIR_DELETE);
}
set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT | maybe_ATTRS_SET_NANO);
if (itemizing)
itemize(fnamecmp, file, ndx, statret, &sx, 0, 0, NULL);
#ifdef SUPPORT_HARD_LINKS
Expand Down
6 changes: 3 additions & 3 deletions rsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
if (!(flags & ATTRS_SKIP_MTIME)
&& (sxp->st.st_mtime != file->modtime
#ifdef ST_MTIME_NSEC
|| (NSEC_BUMP(file) && (uint32)sxp->st.ST_MTIME_NSEC != F_MOD_NSEC(file))
|| (flags & ATTRS_SET_NANO && NSEC_BUMP(file) && (uint32)sxp->st.ST_MTIME_NSEC != F_MOD_NSEC(file))
#endif
)) {
int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode);
Expand Down Expand Up @@ -672,7 +672,7 @@ int finish_transfer(const char *fname, const char *fnametmp,

/* Change permissions before putting the file into place. */
set_file_attrs(fnametmp, file, NULL, fnamecmp,
ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
ok_to_set_time ? ATTRS_SET_NANO : ATTRS_SKIP_MTIME);

/* move tmp file over real file */
if (DEBUG_GTE(RECV, 1))
Expand All @@ -697,7 +697,7 @@ int finish_transfer(const char *fname, const char *fnametmp,

do_set_file_attrs:
set_file_attrs(fnametmp, file, NULL, fnamecmp,
ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
ok_to_set_time ? ATTRS_SET_NANO : ATTRS_SKIP_MTIME);

if (temp_copy_name) {
if (do_rename(fnametmp, fname) < 0) {
Expand Down
1 change: 1 addition & 0 deletions rsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@

#define ATTRS_REPORT (1<<0)
#define ATTRS_SKIP_MTIME (1<<1)
#define ATTRS_SET_NANO (1<<2)

#define FULL_FLUSH 1
#define NORMAL_FLUSH 0
Expand Down

0 comments on commit 0f8e9e2

Please sign in to comment.