From ffbcde002241bf1584099499dabbbcbb4eae27d4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 2 Dec 2024 14:07:45 +0100 Subject: [PATCH] curl: --continue-at is mutually exclusive with --no-clobber Test 481 verifies Fixes #15645 Reported-by: Harry Sintonen Closes #15668 --- docs/cmdline-opts/continue-at.md | 2 ++ docs/cmdline-opts/no-clobber.md | 2 ++ src/tool_getparam.c | 10 +++++++ tests/data/Makefile.am | 2 +- tests/data/test481 | 45 ++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/data/test481 diff --git a/docs/cmdline-opts/continue-at.md b/docs/cmdline-opts/continue-at.md index e57671c350..607cf4c0fd 100644 --- a/docs/cmdline-opts/continue-at.md +++ b/docs/cmdline-opts/continue-at.md @@ -27,3 +27,5 @@ transfer. It then uses the given output/input files to figure that out. This command line option is mutually exclusive with --range: you can only use one of them for a single transfer. + +The --no-clobber option cannot be used together with --continue-at. diff --git a/docs/cmdline-opts/no-clobber.md b/docs/cmdline-opts/no-clobber.md index 6909005638..02a74b25e4 100644 --- a/docs/cmdline-opts/no-clobber.md +++ b/docs/cmdline-opts/no-clobber.md @@ -24,3 +24,5 @@ create any file. Note that this is the negated option name documented. You can thus use --clobber to enforce the clobbering, even if --remote-header-name is specified. + +The --continue-at option cannot be used together with --no-clobber. diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 7c31ca1cb6..c7da51ae1a 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -1849,6 +1849,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ errorf(global, "--continue-at is mutually exclusive with --range"); return PARAM_BAD_USE; } + if(config->file_clobber_mode == CLOBBER_NEVER) { + errorf(config->global, + "--continue-at is mutually exclusive with --no-clobber"); + return PARAM_BAD_USE; + } /* This makes us continue an ftp transfer at given position */ if(strcmp(nextarg, "-")) { err = str2offset(&config->resume_from, nextarg); @@ -2320,6 +2325,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ err = getstr(&config->output_dir, nextarg, DENY_BLANK); break; case C_CLOBBER: /* --clobber */ + if(config->use_resume && !toggle) { + errorf(config->global, + "--continue-at is mutually exclusive with --no-clobber"); + return PARAM_BAD_USE; + } config->file_clobber_mode = toggle ? CLOBBER_ALWAYS : CLOBBER_NEVER; break; case C_OUTPUT: /* --output */ diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 53f62c6e28..d13811a4fa 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -77,7 +77,7 @@ test435 test436 test437 test438 test439 test440 test441 test442 test443 \ test444 test445 test446 test447 test448 test449 test450 test451 test452 \ test453 test454 test455 test456 test457 test458 test459 test460 test461 \ test462 test463 test467 test468 test469 test470 test471 test472 test473 \ -test474 test475 test476 test477 test478 test479 test480 \ +test474 test475 test476 test477 test478 test479 test480 test481 \ \ test490 test491 test492 test493 test494 test495 test496 test497 test498 \ test499 test500 test501 test502 test503 test504 test505 test506 test507 \ diff --git a/tests/data/test481 b/tests/data/test481 new file mode 100644 index 0000000000..f59fec2f9f --- /dev/null +++ b/tests/data/test481 @@ -0,0 +1,45 @@ + + + +HTTP +HTTP GET +--no-clobber +--continue-at + + + +# +# Server-side + + + +# +# Client-side + + +http + + +--no-clobber with --continue-at + + +initial content + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER --no-clobber -C 1 -o "%LOGDIR/%TESTNUMBER" + + + +# +# Verify data after the test has been "shot" + + +2 + + +curl: --continue-at is mutually exclusive with --no-clobber +curl: option -C: is badly used here +curl: try 'curl --help' or 'curl --manual' for more information + + + -- 2.47.3