Commit 936fa865 authored by Wayne Davison's avatar Wayne Davison

Handle the new --append and --append-verify options.

parent 2f188c8d
...@@ -315,21 +315,23 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len) ...@@ -315,21 +315,23 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
sum_init(checksum_seed); sum_init(checksum_seed);
if (append_mode > 0) { if (append_mode > 0) {
OFF_T j = 0; if (append_mode == 2) {
for (j = CHUNK_SIZE; j < s->flength; j += CHUNK_SIZE) { OFF_T j = 0;
if (buf && do_progress) for (j = CHUNK_SIZE; j < s->flength; j += CHUNK_SIZE) {
show_progress(last_match, buf->file_size); if (buf && do_progress)
sum_update(map_ptr(buf, last_match, CHUNK_SIZE), show_progress(last_match, buf->file_size);
CHUNK_SIZE); sum_update(map_ptr(buf, last_match, CHUNK_SIZE),
last_match = j; CHUNK_SIZE);
} last_match = j;
if (last_match < s->flength) { }
int32 n = (int32)(s->flength - last_match); if (last_match < s->flength) {
if (buf && do_progress) int32 n = (int32)(s->flength - last_match);
show_progress(last_match, buf->file_size); if (buf && do_progress)
sum_update(map_ptr(buf, last_match, n), n); show_progress(last_match, buf->file_size);
last_match = s->flength; sum_update(map_ptr(buf, last_match, n), n);
}
} }
last_match = s->flength;
s->count = 0; s->count = 0;
} }
......
...@@ -319,6 +319,7 @@ void usage(enum logcode F) ...@@ -319,6 +319,7 @@ void usage(enum logcode F)
rprintf(F," -u, --update skip files that are newer on the receiver\n"); 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," --inplace update destination files in-place (SEE MAN PAGE)\n");
rprintf(F," --append append data onto shorter files\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," -d, --dirs transfer directories without recursing\n");
rprintf(F," -l, --links copy symlinks as symlinks\n"); rprintf(F," -l, --links copy symlinks as symlinks\n");
rprintf(F," -L, --copy-links transform symlink into referent file/dir\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, ...@@ -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_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_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_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}; OPT_SERVER, OPT_REFUSED_BASE = 9000};
static struct poptOption long_options[] = { static struct poptOption long_options[] = {
...@@ -521,7 +522,9 @@ 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 }, {"min-size", 0, POPT_ARG_STRING, &min_size_arg, OPT_MIN_SIZE, 0, 0 },
{"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 }, {"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 },
{"inplace", 0, POPT_ARG_NONE, &inplace, 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 }, {"del", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 },
{"delete", 0, POPT_ARG_NONE, &delete_mode, 0, 0, 0 }, {"delete", 0, POPT_ARG_NONE, &delete_mode, 0, 0, 0 },
{"delete-before", 0, POPT_ARG_NONE, &delete_before, 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) ...@@ -1121,6 +1124,13 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
} }
break; break;
case OPT_APPEND:
if (am_server)
append_mode++;
else
append_mode = 1;
break;
case OPT_LINK_DEST: case OPT_LINK_DEST:
#ifdef SUPPORT_HARD_LINKS #ifdef SUPPORT_HARD_LINKS
link_dest = 1; link_dest = 1;
...@@ -1912,9 +1922,11 @@ void server_options(char **args,int *argc) ...@@ -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"; args[ac++] = "--append";
else if (inplace) } else if (inplace)
args[ac++] = "--inplace"; args[ac++] = "--inplace";
if (files_from && (!am_sender || filesfrom_host)) { if (files_from && (!am_sender || filesfrom_host)) {
......
...@@ -157,20 +157,22 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, ...@@ -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; sum.flength = (OFF_T)sum.count * sum.blength;
if (sum.remainder) if (sum.remainder)
sum.flength -= sum.blength - sum.remainder; sum.flength -= sum.blength - sum.remainder;
for (j = CHUNK_SIZE; j < sum.flength; j += CHUNK_SIZE) { if (append_mode == 2) {
if (do_progress) for (j = CHUNK_SIZE; j < sum.flength; j += CHUNK_SIZE) {
show_progress(offset, total_size); if (do_progress)
sum_update(map_ptr(mapbuf, offset, CHUNK_SIZE), show_progress(offset, total_size);
CHUNK_SIZE); sum_update(map_ptr(mapbuf, offset, CHUNK_SIZE),
offset = j; CHUNK_SIZE);
} offset = j;
if (offset < sum.flength) { }
int32 len = (int32)(sum.flength - offset); if (offset < sum.flength) {
if (do_progress) int32 len = (int32)(sum.flength - offset);
show_progress(offset, total_size); if (do_progress)
sum_update(map_ptr(mapbuf, offset, len), len); show_progress(offset, total_size);
offset = sum.flength; sum_update(map_ptr(mapbuf, offset, len), len);
}
} }
offset = sum.flength;
if (fd != -1 && (j = do_lseek(fd, offset, SEEK_SET)) != offset) { if (fd != -1 && (j = do_lseek(fd, offset, SEEK_SET)) != offset) {
rsyserr(FERROR, errno, "lseek of %s returned %.0f, not %.0f", rsyserr(FERROR, errno, "lseek of %s returned %.0f, not %.0f",
full_fname(fname), (double)j, (double)offset); full_fname(fname), (double)j, (double)offset);
...@@ -426,8 +428,9 @@ int recv_files(int f_in, char *local_name) ...@@ -426,8 +428,9 @@ int recv_files(int f_in, char *local_name)
if (csum_length == SHORT_SUM_LENGTH) { if (csum_length == SHORT_SUM_LENGTH) {
if (keep_partial && !partial_dir) if (keep_partial && !partial_dir)
make_backups = -make_backups; /* prevents double backup */ make_backups = -make_backups; /* prevents double backup */
if (append_mode)
sparse_files = -sparse_files;
append_mode = -append_mode; append_mode = -append_mode;
sparse_files = -sparse_files;
csum_length = SUM_LENGTH; csum_length = SUM_LENGTH;
redoing = 1; redoing = 1;
} }
...@@ -435,8 +438,9 @@ int recv_files(int f_in, char *local_name) ...@@ -435,8 +438,9 @@ int recv_files(int f_in, char *local_name)
if (csum_length != SHORT_SUM_LENGTH) { if (csum_length != SHORT_SUM_LENGTH) {
if (keep_partial && !partial_dir) if (keep_partial && !partial_dir)
make_backups = -make_backups; make_backups = -make_backups;
if (append_mode)
sparse_files = -sparse_files;
append_mode = -append_mode; append_mode = -append_mode;
sparse_files = -sparse_files;
csum_length = SHORT_SUM_LENGTH; csum_length = SHORT_SUM_LENGTH;
redoing = 0; redoing = 0;
} }
......
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