feat: add rsync-compatible size-only option
CI / lint (pull_request) Successful in 12s
CI / sanitizers (address) (pull_request) Successful in 37s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m16s
CI / valgrind (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 12s
CI / sanitizers (address) (pull_request) Successful in 37s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m16s
CI / valgrind (pull_request) Successful in 33s
This commit is contained in:
@@ -139,6 +139,7 @@ static const OptionEntry OPTION_TABLE[] = {
|
||||
{"--dry-run", "-n", OPT_FLAG, offsetof(Config, dry_run)},
|
||||
{"--delete", NULL, OPT_FLAG, offsetof(Config, use_delete)},
|
||||
{"--incremental", NULL, OPT_FLAG, offsetof(Config, use_incremental)},
|
||||
{"--size-only", NULL, OPT_FLAG, offsetof(Config, size_only)},
|
||||
{"--delta", NULL, OPT_FLAG, offsetof(Config, use_delta)},
|
||||
{"--save-to-disk", NULL, OPT_FLAG, offsetof(Config, save_to_disk)},
|
||||
{"--progress", NULL, OPT_FLAG, offsetof(Config, show_progress)},
|
||||
|
||||
@@ -28,6 +28,7 @@ void print_usage(void) {
|
||||
printf(" --max-size <n> Skip files larger than n bytes\n");
|
||||
printf(" --min-size <n> Skip files smaller than n bytes\n");
|
||||
printf(" --incremental Skip files unchanged since last transfer\n");
|
||||
printf(" --size-only Skip incremental files matching in size, ignoring mtime\n");
|
||||
printf(" --delta Delta transfer for changed files (requires --incremental)\n");
|
||||
printf(" --delta-block <n> Delta block size in bytes (default: %d)\n",
|
||||
DELTA_BLOCK_SIZE_DEFAULT);
|
||||
|
||||
@@ -61,7 +61,7 @@ static bool receiver_process_batch(Config* config, int file_descriptor) {
|
||||
struct stat st;
|
||||
bool has_old = file_stat_secure(full_path, &st);
|
||||
bool match = has_old && (unsigned long long)st.st_size == check_size &&
|
||||
(long long)st.st_mtime == check_mtime;
|
||||
(config->size_only || (long long)st.st_mtime == check_mtime);
|
||||
bool sent = send_status(file_descriptor, match ? STATUS_OK : STATUS_NEXT);
|
||||
free(full_path);
|
||||
free(check_path);
|
||||
|
||||
+1
-1
@@ -175,7 +175,7 @@ int receive_files(Config* config, int fd) {
|
||||
}
|
||||
bool has_old = full_path && file_stat_secure(full_path, &st);
|
||||
bool match = has_old && (unsigned long long)st.st_size == check_size &&
|
||||
(long long)st.st_mtime == check_mtime;
|
||||
(config->size_only || (long long)st.st_mtime == check_mtime);
|
||||
bool sent = send_status(fd, match ? STATUS_OK : STATUS_NEXT);
|
||||
free(full_path);
|
||||
free(check_path);
|
||||
|
||||
+8
-5
@@ -34,6 +34,7 @@ static void config_set_defaults(Config* config) {
|
||||
config->max_size = 0;
|
||||
config->min_size = 0;
|
||||
config->use_incremental = false;
|
||||
config->size_only = false;
|
||||
config->use_delta = false;
|
||||
config->delta_block_size = DELTA_BLOCK_SIZE_DEFAULT;
|
||||
config->delta_max_file_size = DELTA_MAX_FILE_SIZE;
|
||||
@@ -117,10 +118,10 @@ static bool validate_received_config(const Config* config) {
|
||||
valid_wire_bool(config->use_chunk_serialization) &&
|
||||
valid_wire_bool(config->use_compression) && valid_wire_bool(config->use_metadata) &&
|
||||
valid_wire_bool(config->use_sendfile) && valid_wire_bool(config->use_delete) &&
|
||||
valid_wire_bool(config->use_incremental) && valid_wire_bool(config->use_delta) &&
|
||||
valid_wire_bool(config->backup) && valid_wire_bool(config->follow_symlinks) &&
|
||||
valid_wire_bool(config->copy_links) && valid_wire_bool(config->safe_links) &&
|
||||
valid_wire_bool(config->copy_unsafe_links) &&
|
||||
valid_wire_bool(config->use_incremental) && valid_wire_bool(config->size_only) &&
|
||||
valid_wire_bool(config->use_delta) && valid_wire_bool(config->backup) &&
|
||||
valid_wire_bool(config->follow_symlinks) && valid_wire_bool(config->copy_links) &&
|
||||
valid_wire_bool(config->safe_links) && valid_wire_bool(config->copy_unsafe_links) &&
|
||||
valid_wire_bool(config->preserve_hard_links) && valid_wire_bool(config->preserve_acls) &&
|
||||
valid_wire_bool(config->preserve_xattrs) && valid_wire_bool(config->preserve_devices) &&
|
||||
valid_wire_bool(config->preserve_sparse) && valid_wire_bool(config->update) &&
|
||||
@@ -228,7 +229,7 @@ static bool send_core_fields(int fd, const Config* c) {
|
||||
|
||||
static bool send_delta_fields(int fd, const Config* c) {
|
||||
return send_int(fd, c->use_delete) && send_int(fd, c->use_incremental) &&
|
||||
send_int(fd, c->use_delta) &&
|
||||
send_int(fd, c->size_only) && send_int(fd, c->use_delta) &&
|
||||
send_n_data(fd, &c->delta_block_size, sizeof(c->delta_block_size)) &&
|
||||
send_n_data(fd, &c->delta_max_file_size, sizeof(unsigned long long));
|
||||
}
|
||||
@@ -281,6 +282,8 @@ static bool receive_delta_fields(int fd, Config* c) {
|
||||
return false;
|
||||
if (!receive_wire_bool(fd, &c->use_incremental))
|
||||
return false;
|
||||
if (!receive_wire_bool(fd, &c->size_only))
|
||||
return false;
|
||||
if (!receive_wire_bool(fd, &c->use_delta))
|
||||
return false;
|
||||
return receive_n_data(fd, &c->delta_block_size, sizeof(c->delta_block_size)) &&
|
||||
|
||||
@@ -34,6 +34,7 @@ typedef struct Config {
|
||||
unsigned long long max_size;
|
||||
unsigned long long min_size;
|
||||
bool use_incremental;
|
||||
bool size_only;
|
||||
bool use_delta;
|
||||
uint32_t delta_block_size;
|
||||
unsigned long long delta_max_file_size;
|
||||
|
||||
@@ -383,7 +383,7 @@ File* receive_incremental_check(int fd, const Config* config, bool* skipped) {
|
||||
match = (old_size == 0 || old_data) && old_checksum == check_checksum;
|
||||
free(old_data);
|
||||
old_data = NULL;
|
||||
} else if (match) {
|
||||
} else if (match && !config->size_only) {
|
||||
match = (long long)st.st_mtime == check_mtime;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user