Merge feat/p2-temp-dir: implement --temp-dir

Receiver writes temps into a confined scratch dir and atomically renames
into place; EXDEV aborts; inplace/partial bypass; thread-safe temp names.
Uses existing wire field; no protocol bump. Reviewed (c-review APPROVE
WITH NITS, all fixed); PR #262.
This commit is contained in:
2026-09-06 12:52:11 +02:00
10 changed files with 363 additions and 38 deletions
+29 -1
View File
@@ -620,7 +620,6 @@ static void test_parse_args_rejects_unimplemented_options() {
"-e",
"--rsh",
"--rsync-path",
"--temp-dir",
"--compare-dest",
"--copy-dest",
"--link-dest",
@@ -840,6 +839,34 @@ static void test_parse_args_checksum_choice_requires_value() {
}
}
/* --temp-dir accepts both the "--temp-dir=DIR" and "--temp-dir DIR" forms. */
static void test_parse_args_temp_dir() {
Config* cfg = config_create();
char* equals_argv[] = {"fastsync", "--temp-dir=scratch", "/src", "/dst"};
int positional_args[2];
int positional_count = 0;
EXPECT_EQ_INT(parse_args(cfg, 4, equals_argv, positional_args, &positional_count), 0);
EXPECT_EQ_STR(cfg->temp_dir, "scratch");
EXPECT_EQ_INT(positional_count, 2);
config_delete(cfg);
cfg = config_create();
char* space_argv[] = {"fastsync", "--temp-dir", "scratch/sub", "/src", "/dst"};
positional_count = 0;
EXPECT_EQ_INT(parse_args(cfg, 5, space_argv, positional_args, &positional_count), 0);
EXPECT_EQ_STR(cfg->temp_dir, "scratch/sub");
EXPECT_EQ_INT(positional_count, 2);
config_delete(cfg);
/* A value-taking option may not be passed without a value. */
cfg = config_create();
char* missing_argv[] = {"fastsync", "--temp-dir"};
positional_count = 0;
EXPECT_EQ_INT(parse_args(cfg, 2, missing_argv, positional_args, &positional_count), -1);
config_delete(cfg);
}
static void test_parse_args_old_args() {
Config* cfg = config_create();
char* argv[] = {"fastsync", "--old-args", "/src", "/dst"};
@@ -1255,4 +1282,5 @@ void test_client_cli() {
test_parse_args_partial_progress();
test_parse_args_checksum_choice_aliases();
test_parse_args_checksum_choice_requires_value();
test_parse_args_temp_dir();
}