Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool_operate: don't truncate the etag save file by default #13432

Closed
wants to merge 1 commit into from

Conversation

Gusted
Copy link
Contributor

@Gusted Gusted commented Apr 20, 2024

This fixes a regression of 75d79a4. The code in tool-operate truncated the etag save file, under the assumption that the file would be written with a new etag value. However since 75d79a4 that might not be the case anymore and could result in the file being truncated when --etag-compare and --etag-save was used and that the etag value matched with what the server responded. Instead the truncation should not be done when a new etag value should be written.

Test 3204 was added to verify that the file with the etag value doesn't change the contents when used by --etag-compare and --etage-save and that value matches with what the server returns on a non 2xx response.

A simple reproducer of this bug is using the command as advertised in the blog post:

curl --etag-compare etag.txt --etag-save etag.txt https://example.com -o saved-file

Run it three times and notice that for the second time it indeed doesn't download anything but for the third time it does, because on the second time the etag.txt is being truncated and nothing is being written back.

This fixes a regression of 75d79a4. The
code in tool-operate truncated the etag save file, under the assumption
that the file would be written with a new etag value. However since
75d79a4 that might not be the case
anymore and could result in the file being truncated when --etag-compare
and --etag-save was used and that the etag value matched with what the
server responded. Instead the truncation should not be done when a new
etag value should be written.

Test 3204 was added to verify that the file with the etag value doesn't
change the contents when used by --etag-compare and --etage-save and
that value matches with what the server returns on a non 2xx response.
src/tool_operate.c Dismissed Show resolved Hide resolved
@bagder bagder self-assigned this Apr 22, 2024
@bagder
Copy link
Member

bagder commented Apr 23, 2024

Thanks!

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.

None yet

2 participants