diff --git a/README.md b/README.md index fdbd9f3..6873f7c 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,8 @@ features without changing the meaning of ordinary compatibility options. | `-m` | Enable the multithreaded scanner/loader/sender pipeline. | | `-c [level]`, `-z [level]` | Enable streaming zstd compression, levels 1-22. | | `--compress-level ` | Set the zstd compression level. | +| `--zc ` | Alias for `--compress-choice`. FastSync supports `zstd` and `none`. | +| `--zl ` | Alias for `--compress-level`. | | `--chunk-size ` | Set the transfer chunk size. | | `-s` | Enable FastSync chunk serialization. | | `-f`, `--sendfile` | Use TCP `sendfile()` zero-copy transfer. Incompatible with compression and chunk serialization. | diff --git a/RSYNC_COMPAT.md b/RSYNC_COMPAT.md index 4b236ec..95a9224 100644 --- a/RSYNC_COMPAT.md +++ b/RSYNC_COMPAT.md @@ -171,8 +171,8 @@ This document maps rsync's full feature set to FastSync's current implementation | Flag | Rsync Description | FastSync Status | Notes | |------|-------------------|-----------------|-------| | `-z`, `--compress` | Compress file data | 🔀 Alt Arg | Always uses zstd (rsync supports multiple algorithms) | -| `--compress-choice=STR` | Choose compression algorithm | ❌ Not Implemented | Removed because it had no effect; FastSync always uses zstd | -| `--compress-level=NUM` | Set compression level | ✅ Implemented | 1-22, default 5 | +| `--compress-choice=STR`, `--zc=STR` | Choose compression algorithm | ✅ Implemented | FastSync supports `zstd` and `none` | +| `--compress-level=NUM`, `--zl=NUM` | Set compression level | ✅ Implemented | 1-22, default 5 | | `--compress-threads=NUM` | Set compression threads | ❌ Not Implemented | | | `--skip-compress=LIST` | Skip compress for suffixes | ❌ Not Implemented | Internal skip for hardcoded types; not user-configurable | diff --git a/src/client/client_cli.c b/src/client/client_cli.c index 191cc07..dfe39ee 100644 --- a/src/client/client_cli.c +++ b/src/client/client_cli.c @@ -164,6 +164,7 @@ static const OptionEntry OPTION_TABLE[] = { {"--fastsync-server-path", NULL, OPT_STRING, offsetof(Config, fastsync_server_path)}, {"--partial-dir", NULL, OPT_STRING, offsetof(Config, partial_dir)}, {"--suffix", NULL, OPT_STRING, offsetof(Config, suffix)}, + {"--compress-choice", "--zc", OPT_STRING, offsetof(Config, compress_choice)}, {"--timeout", NULL, OPT_POS_INT, offsetof(Config, timeout)}, {"--contimeout", NULL, OPT_POS_INT, offsetof(Config, contimeout)}, @@ -354,7 +355,7 @@ int parse_args(Config* config, int argc, char* argv[], int* positional_args, } else if (opt_is(argv[i], "-T", NULL) && i + 1 < argc) { if (set_positive_int_option(&config->timeout, argv[++i], "-T") != 0) return -1; - } else if (opt_is(argv[i], "--compress-level", NULL) && i + 1 < argc) { + } else if (opt_is(argv[i], "--compress-level", "--zl") && i + 1 < argc) { if (set_positive_int_option(&config->compression_level, argv[++i], "--compress-level") != 0) return -1; if (config->compression_level < 1 || config->compression_level > 22) { diff --git a/src/client/usage.c b/src/client/usage.c index 2f800af..508136c 100644 --- a/src/client/usage.c +++ b/src/client/usage.c @@ -36,6 +36,8 @@ void print_usage(void) { printf(" -m Enable multithreading\n"); printf(" -s Enable chunk serialization\n"); printf(" -f Enable sendfile (TCP only, not with -c or -s)\n"); + printf(" --compress-choice Compression algorithm (default: zstd)\n"); + printf(" --zc Alias for --compress-choice\n"); printf(" -v, --verbose Enable debug logging\n"); printf(" -M, --preserve Preserve file metadata\n"); printf(" --chunk-size Chunk size in bytes (default: %d)\n", DEFAULT_CHUNK_SIZE); @@ -69,6 +71,7 @@ void print_usage(void) { printf(" -S, --sparse Handle sparse files efficiently\n"); printf(" --inplace Update files in-place (no temp+rename)\n"); printf(" --compress-level Compression level (default: 5)\n"); + printf(" --zl Alias for --compress-level\n"); printf(" --help Show this help\n"); printf(" -V, --version Show version\n"); } diff --git a/tests/test_client_cli.c b/tests/test_client_cli.c index 656fd40..9a9d7d1 100644 --- a/tests/test_client_cli.c +++ b/tests/test_client_cli.c @@ -310,7 +310,7 @@ static void test_parse_args_rejects_unimplemented_options() { "--daemon", "--config", "--server", - "--compress-choice"}; + "--checksum-choice"}; for (size_t i = 0; i < sizeof(options) / sizeof(options[0]); i++) { Config* cfg = config_create(); @@ -339,6 +339,22 @@ static void test_parse_args_archive() { config_delete(cfg); } +/* Test rsync-compatible compression-choice and compression-level aliases. */ +static void test_parse_args_compression_aliases() { + Config* cfg = config_create(); + char* argv[] = {"fastsync", "--zc", "zstd", "--zl", "10", "/src", "/dst"}; + int positional_args[2]; + int positional_count = 0; + + int ret = parse_args(cfg, 7, argv, positional_args, &positional_count); + EXPECT_EQ_INT(ret, 0); + EXPECT_EQ_STR(cfg->compress_choice, "zstd"); + EXPECT_EQ_INT(cfg->compression_level, 10); + EXPECT_EQ_INT(positional_count, 2); + + config_delete(cfg); +} + void test_client_cli() { test_validate_config_required_paths(); test_validate_config_incompatible_options(); @@ -360,4 +376,5 @@ void test_client_cli() { test_parse_args_unknown_option(); test_parse_args_rejects_unimplemented_options(); test_parse_args_archive(); + test_parse_args_compression_aliases(); }