Skip to content

tool_cb_wrt: inject the no-clobber number before the extension - #22787

Closed
bagder wants to merge 3 commits into
masterfrom
bagder/no-clobber-name
Closed

bagder wants to merge 3 commits into
masterfrom
bagder/no-clobber-name

Conversation

@bagder

@bagder bagder commented Sep 1, 2026

Copy link
Copy Markdown
Member

Starting in curl 8.23.0, if the target file name uses an extension, curl instead creates the new file name by inserting -[num] before the extenstion. Downloading to image.jpg with --no-clobber, curl first tries to save it as image-1.jpg then image-2.jpg etc.

@bagder
bagder marked this pull request as ready for review September 1, 2026 16:23
@bagder
bagder requested a lite review from Copilot September 3, 2026 06:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new extension detection currently scans the full path (not just the basename), which can generate incorrect output paths when directories contain dots or when the basename begins with a dot.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates curl’s --no-clobber filename generation so that when the requested output name has an extension, the numeric suffix is injected before the extension (e.g., image-1.jpg), and documents the new behavior.

Changes:

  • Refactors output filename retry logic into a helper that inserts -N before the extension.
  • Updates --no-clobber option documentation to describe the extension-aware naming scheme.
File summaries
File Description
src/tool_cb_wrt.c Adds clobber_name() and switches retry naming to insert the number before the extension.
docs/cmdline-opts/no-clobber.md Documents the new extension-aware --no-clobber filename behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/tool_cb_wrt.c Outdated
Comment thread src/tool_cb_wrt.c Outdated
Starting in curl 8.23.0, if the target file name uses an extension, curl
instead creates the new file name by inserting `-[num]` before the
extenstion. Downloading to `image.jpg` with --no-clobber, curl first
tries to save it as `image-1.jpg` then `image-2.jpg` etc.

Closes #22787

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

All reviewed changes are covered with tests and documentation, with no unresolved issues.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@bagder bagder closed this in f89eca9 Sep 4, 2026
@bagder
bagder deleted the bagder/no-clobber-name branch September 4, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants