mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-10-21 13:24:15 -04:00
Handle the new --append and --append-verify options.
This commit is contained in:
1 parent
2f188c8d96
commit
936fa865e1
3 files changed
+51
-33
No files matched your search
@@ -315,21 +315,23 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
|
||||
sum_init(checksum_seed);
|
||||
|
||||
if (append_mode > 0) {
|
||||
OFF_T j = 0;
|
||||
for (j = CHUNK_SIZE; j < s->flength; j += CHUNK_SIZE) {
|
||||
if (buf && do_progress)
|
||||
show_progress(last_match, buf->file_size);
|
||||
sum_update(map_ptr(buf, last_match, CHUNK_SIZE),
|
||||
CHUNK_SIZE);
|
||||
last_match = j;
|
||||
}
|
||||
if (last_match < s->flength) {
|
||||
int32 n = (int32)(s->flength - last_match);
|
||||
if (buf && do_progress)
|
||||
show_progress(last_match, buf->file_size);
|
||||
sum_update(map_ptr(buf, last_match, n), n);
|
||||
last_match = s->flength;
|
||||
if (append_mode == 2) {
|
||||
OFF_T j = 0;
|
||||
for (j = CHUNK_SIZE; j < s->flength; j += CHUNK_SIZE) {
|
||||
if (buf && do_progress)
|
||||
show_progress(last_match, buf->file_size);
|
||||
sum_update(map_ptr(buf, last_match, CHUNK_SIZE),
|
||||
CHUNK_SIZE);
|
||||
last_match = j;
|
||||
}
|
||||
if (last_match < s->flength) {
|
||||
int32 n = (int32)(s->flength - last_match);
|
||||
if (buf && do_progress)
|
||||
show_progress(last_match, buf->file_size);
|
||||
sum_update(map_ptr(buf, last_match, n), n);
|
||||
}
|
||||
}
|
||||
last_match = s->flength;
|
||||
s->count = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -319,6 +319,7 @@ void usage(enum logcode F)
|
||||
rprintf(F," -u, --update skip files that are newer on the receiver\n");
|
||||
rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n");
|
||||
rprintf(F," --append append data onto shorter files\n");
|
||||
rprintf(F," --append-verify like --append, but with old data in file checksum\n");
|
||||
rprintf(F," -d, --dirs transfer directories without recursing\n");
|
||||
rprintf(F," -l, --links copy symlinks as symlinks\n");
|
||||
rprintf(F," -L, --copy-links transform symlink into referent file/dir\n");
|
||||
@@ -434,7 +435,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
|
||||
OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
|
||||
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
|
||||
OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
|
||||
OPT_NO_D,
|
||||
OPT_NO_D, OPT_APPEND,
|
||||
OPT_SERVER, OPT_REFUSED_BASE = 9000};
|
||||
|
||||
static struct poptOption long_options[] = {
|
||||
@@ -521,7 +522,9 @@ static struct poptOption long_options[] = {
|
||||
{"min-size", 0, POPT_ARG_STRING, &min_size_arg, OPT_MIN_SIZE, 0, 0 },
|
||||
{"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 },
|
||||
{"inplace", 0, POPT_ARG_NONE, &inplace, 0, 0, 0 },
|
||||
{"append", 0, POPT_ARG_VAL, &append_mode, 1, 0, 0 },
|
||||
{"append", 0, POPT_ARG_NONE, 0, OPT_APPEND, 0, 0 },
|
||||
{"append-verify", 0, POPT_ARG_VAL, &append_mode, 2, 0, 0 },
|
||||
{"no-append", 0, POPT_ARG_VAL, &append_mode, 0, 0, 0 },
|
||||
{"del", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 },
|
||||
{"delete", 0, POPT_ARG_NONE, &delete_mode, 0, 0, 0 },
|
||||
{"delete-before", 0, POPT_ARG_NONE, &delete_before, 0, 0, 0 },
|
||||
@@ -1121,6 +1124,13 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
|
||||
}
|
||||
break;
|
||||
|
||||
case OPT_APPEND:
|
||||
if (am_server)
|
||||
append_mode++;
|
||||
else
|
||||
append_mode = 1;
|
||||
break;
|
||||
|
||||
case OPT_LINK_DEST:
|
||||
#ifdef SUPPORT_HARD_LINKS
|
||||
link_dest = 1;
|
||||
@@ -1912,9 +1922,11 @@ void server_options(char **args,int *argc)
|
||||
}
|
||||
}
|
||||
|
||||
if (append_mode)
|
||||
if (append_mode) {
|
||||
if (append_mode > 1)
|
||||
args[ac++] = "--append";
|
||||
args[ac++] = "--append";
|
||||
else if (inplace)
|
||||
} else if (inplace)
|
||||
args[ac++] = "--inplace";
|
||||
|
||||
if (files_from && (!am_sender || filesfrom_host)) {
|
||||
|
||||
+19
-15
@@ -157,20 +157,22 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
sum.flength = (OFF_T)sum.count * sum.blength;
|
||||
if (sum.remainder)
|
||||
sum.flength -= sum.blength - sum.remainder;
|
||||
for (j = CHUNK_SIZE; j < sum.flength; j += CHUNK_SIZE) {
|
||||
if (do_progress)
|
||||
show_progress(offset, total_size);
|
||||
sum_update(map_ptr(mapbuf, offset, CHUNK_SIZE),
|
||||
CHUNK_SIZE);
|
||||
offset = j;
|
||||
}
|
||||
if (offset < sum.flength) {
|
||||
int32 len = (int32)(sum.flength - offset);
|
||||
if (do_progress)
|
||||
show_progress(offset, total_size);
|
||||
sum_update(map_ptr(mapbuf, offset, len), len);
|
||||
offset = sum.flength;
|
||||
if (append_mode == 2) {
|
||||
for (j = CHUNK_SIZE; j < sum.flength; j += CHUNK_SIZE) {
|
||||
if (do_progress)
|
||||
show_progress(offset, total_size);
|
||||
sum_update(map_ptr(mapbuf, offset, CHUNK_SIZE),
|
||||
CHUNK_SIZE);
|
||||
offset = j;
|
||||
}
|
||||
if (offset < sum.flength) {
|
||||
int32 len = (int32)(sum.flength - offset);
|
||||
if (do_progress)
|
||||
show_progress(offset, total_size);
|
||||
sum_update(map_ptr(mapbuf, offset, len), len);
|
||||
}
|
||||
}
|
||||
offset = sum.flength;
|
||||
if (fd != -1 && (j = do_lseek(fd, offset, SEEK_SET)) != offset) {
|
||||
rsyserr(FERROR, errno, "lseek of %s returned %.0f, not %.0f",
|
||||
full_fname(fname), (double)j, (double)offset);
|
||||
@@ -426,8 +428,9 @@ int recv_files(int f_in, char *local_name)
|
||||
if (csum_length == SHORT_SUM_LENGTH) {
|
||||
if (keep_partial && !partial_dir)
|
||||
make_backups = -make_backups; /* prevents double backup */
|
||||
if (append_mode)
|
||||
sparse_files = -sparse_files;
|
||||
append_mode = -append_mode;
|
||||
sparse_files = -sparse_files;
|
||||
csum_length = SUM_LENGTH;
|
||||
redoing = 1;
|
||||
}
|
||||
@@ -435,8 +438,9 @@ int recv_files(int f_in, char *local_name)
|
||||
if (csum_length != SHORT_SUM_LENGTH) {
|
||||
if (keep_partial && !partial_dir)
|
||||
make_backups = -make_backups;
|
||||
if (append_mode)
|
||||
sparse_files = -sparse_files;
|
||||
append_mode = -append_mode;
|
||||
sparse_files = -sparse_files;
|
||||
csum_length = SHORT_SUM_LENGTH;
|
||||
redoing = 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user