Skip to content

Add option --time-only #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ extern int make_backups;
extern int csum_length;
extern int ignore_times;
extern int size_only;
extern int time_only;
extern OFF_T max_size;
extern OFF_T min_size;
extern int io_error;
Expand Down Expand Up @@ -618,7 +619,7 @@ int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file
{
switch (ftype) {
case FT_REG:
if (st->st_size != F_LENGTH(file))
if (!time_only && st->st_size != F_LENGTH(file))
return 0;

/* If always_checksum is set then we use the checksum instead
Expand Down
12 changes: 12 additions & 0 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ int safe_symlinks = 0;
int copy_unsafe_links = 0;
int munge_symlinks = 0;
int size_only = 0;
int time_only = 0;
int daemon_bwlimit = 0;
int bwlimit = 0;
int fuzzy_basis = 0;
Expand Down Expand Up @@ -689,6 +690,7 @@ static struct poptOption long_options[] = {
{"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 0, 0 },
{"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
{"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
{"time-only", 0, POPT_ARG_NONE, &time_only, 0, 0, 0 },
{"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
{"no-one-file-system",0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
{"no-x", 0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
Expand Down Expand Up @@ -2835,6 +2837,16 @@ void server_options(char **args, int *argc_p)
args[ac++] = "--super";
if (size_only)
args[ac++] = "--size-only";
/* We don't send --time-only to server because:
* 1. sensible use of the --time-only option requires
* post-processing not done by rsync: compressing transferred
* files and truncating the original while preserving the timestamp.
* 2. older servers would croak.
* It may be a good idea to throw an error with a better error
* message...
*/
// if (time_only)
// args[ac++] = "--time-only";
if (do_stats)
args[ac++] = "--stats";
} else {
Expand Down
17 changes: 16 additions & 1 deletion rsync.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ has its own detailed description later in this manpage.
--contimeout=SECONDS set daemon connection timeout in seconds
--ignore-times, -I don't skip files that match size and time
--size-only skip files that match in size
--time-only skip files that match in time (PULL ONLY)
--modify-window=NUM, -@ set the accuracy for mod-time comparisons
--temp-dir=DIR, -T create temporary files in directory DIR
--fuzzy, -y find similar file for basis if no dest file
Expand Down Expand Up @@ -776,6 +777,19 @@ expand it.
after using another mirroring system which may not preserve timestamps
exactly.

0. `--time-only`

This modifies rsync's "quick check" algorithm for finding files that need
to be transferred, changing it from the default of transferring files with
either a changed size or a changed last-modified time to just looking for
files that have a changed last-modified time, ignoring size changes. This
is useful when remote files are uncompressed but a local copy should be
stored compressed, together with a zero-size stub to prevent re-transfers.
This option is only useful when pulling files, as it requires post-transfer
compression and truncation of files whilst preserving the original
modification time of the stub. Thus the option is not transmitted to the
remote side, also preventing the server from croaking on an unknown option.

0. `--modify-window=NUM`, `-@`

When comparing two timestamps, rsync treats the timestamps as being equal
Expand Down Expand Up @@ -1031,7 +1045,8 @@ expand it.
This forces rsync to skip any files which exist on the destination and have
a modified time that is newer than the source file. (If an existing
destination file has a modification time equal to the source file's, it
will be updated if the sizes are different.)
will be updated if the sizes are different - unless the --time-only flag
is set.)

Note that this does not affect the copying of dirs, symlinks, or other
special files. Also, a difference of file format between the sender and
Expand Down