feat: add whole-file transfer mode
CI / lint (pull_request) Successful in 11s
CI / sanitizers (address) (pull_request) Successful in 38s
CI / sanitizers (undefined) (pull_request) Successful in 38s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 32s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 11s
CI / sanitizers (address) (pull_request) Successful in 38s
CI / sanitizers (undefined) (pull_request) Successful in 38s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 32s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
This commit is contained in:
@@ -213,6 +213,27 @@ class TestIncremental:
|
||||
with open(received_file, "rb") as f:
|
||||
assert f.read() == b"hello world\n"
|
||||
|
||||
def test_whole_file_disables_delta_and_keeps_compression(self, shared_server):
|
||||
clean_dir(DEST_DIR)
|
||||
result, _ = run_client(SOURCE_DIR, DEST_DIR, flags=["-M"], port=shared_server.port)
|
||||
assert result.returncode == 0
|
||||
|
||||
source_file = os.path.join(SOURCE_DIR, "medium.txt")
|
||||
with open(source_file, "wb") as f:
|
||||
f.write(b"whole-file replacement\n" * 5000)
|
||||
|
||||
result, _ = run_client(
|
||||
SOURCE_DIR,
|
||||
DEST_DIR,
|
||||
flags=["-M", "--incremental", "--delta", "-W", "-c"],
|
||||
port=shared_server.port,
|
||||
)
|
||||
assert result.returncode == 0, f"Whole-file sync failed: {(result.stderr or result.stdout)[:200]}"
|
||||
received = get_dest_received_dir(DEST_DIR, SOURCE_DIR)
|
||||
mismatches, missing = verify_transfer(SOURCE_DIR, received)
|
||||
assert not missing, f"Missing: {missing}"
|
||||
assert not mismatches, f"Mismatch: {mismatches}"
|
||||
|
||||
|
||||
class TestDelete:
|
||||
def test_delete_removes_extra_files(self, shared_server):
|
||||
|
||||
@@ -339,6 +339,26 @@ static void test_parse_args_archive() {
|
||||
config_delete(cfg);
|
||||
}
|
||||
|
||||
/* Test both whole-file spellings and its precedence over delta selection. */
|
||||
static void test_parse_args_whole_file() {
|
||||
Config* cfg = config_create();
|
||||
char* argv[] = {"fastsync", "--delta", "--incremental", "-W", "/src", "/dst"};
|
||||
int positional_args[2];
|
||||
int positional_count = 0;
|
||||
|
||||
EXPECT_EQ_INT(parse_args(cfg, 6, argv, positional_args, &positional_count), 0);
|
||||
EXPECT_TRUE(cfg->whole_file);
|
||||
EXPECT_TRUE(cfg->use_delta);
|
||||
|
||||
config_delete(cfg);
|
||||
cfg = config_create();
|
||||
char* long_argv[] = {"fastsync", "--whole-file", "/src", "/dst"};
|
||||
positional_count = 0;
|
||||
EXPECT_EQ_INT(parse_args(cfg, 4, long_argv, positional_args, &positional_count), 0);
|
||||
EXPECT_TRUE(cfg->whole_file);
|
||||
config_delete(cfg);
|
||||
}
|
||||
|
||||
void test_client_cli() {
|
||||
test_validate_config_required_paths();
|
||||
test_validate_config_incompatible_options();
|
||||
@@ -360,4 +380,5 @@ void test_client_cli() {
|
||||
test_parse_args_unknown_option();
|
||||
test_parse_args_rejects_unimplemented_options();
|
||||
test_parse_args_archive();
|
||||
test_parse_args_whole_file();
|
||||
}
|
||||
|
||||
@@ -124,6 +124,8 @@ static void test_config_send_receive() {
|
||||
send_cfg->use_chunk_serialization = true;
|
||||
send_cfg->use_compression = true;
|
||||
send_cfg->use_metadata = true;
|
||||
send_cfg->use_delta = true;
|
||||
send_cfg->whole_file = true;
|
||||
send_cfg->compression_level = 5;
|
||||
send_cfg->chunk_size = 1024;
|
||||
|
||||
@@ -160,6 +162,8 @@ static void test_config_send_receive() {
|
||||
ok = false;
|
||||
if (recv_cfg->chunk_size != 1024)
|
||||
ok = false;
|
||||
if (recv_cfg->use_delta)
|
||||
ok = false;
|
||||
}
|
||||
config_delete(recv_cfg);
|
||||
close(p[0]);
|
||||
|
||||
Reference in New Issue
Block a user