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

win_get_url checksum does not work as expected with force=false #717

Open
KBjorndal-VizRT opened this issue Dec 30, 2024 · 1 comment · May be fixed by #718
Open

win_get_url checksum does not work as expected with force=false #717

KBjorndal-VizRT opened this issue Dec 30, 2024 · 1 comment · May be fixed by #718

Comments

@KBjorndal-VizRT
Copy link

SUMMARY

There is currently no way to use win_get_url and be sure that the expected file is in place without doing extra HTTP requests that waste resources.

If using a checksum and force=true (which to me is a surprising default) the file is always re-downloaded, which if it is pointed to public download sources is inefficient and consumes other peoples resources for no good reason. If force=false a HTTP HEAD request with If-Modified-Since is done, but this is not always enough to ensure that the correct file is downloaded (the local file might have a later modification time than the file on the server).

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

win_get_url

ADDITIONAL INFORMATION

There are two ways in which the behaviour of the posix get_url module is better:

  1. If the dest file exists and has the correct checksum no HTTP request is done. I cannot see a reason why doing a HTTP request in this case actually makes sense.
  2. If dest exists and checksum is different from what is passed in it works as if force=true was passed. Which means you cannot end up in the situation that the module returns ok/no change while the file on disk has a different checksum than what is requested.

If win_get_url was changed to do these two things we could set force=false and be confident that the contents of dest is the file corresponding to the checksum.

$ echo hello > ~/public_html/tmp/hello.txt 
$ echo hei > ~/public_html/tmp/hei.txt 
$ sha1sum ~/public_html/tmp/{hello,hei}.txt 
f572d396fae9206628714fb2ce00f72e94f2258f  /home/kbj/public_html/tmp/hello.txt
b7a7bf03dcafd4d48001d6a2a6fd2ceaefa4cc1e  /home/kbj/public_html/tmp/hei.txt
- hosts: somewhere.example.invalid
  become: no
  tasks:
    - win_get_url:
        url: https://otherplace.example.invalid/~kbj/tmp/hello.txt
        dest: C:/Windows/Temp/greeting.txt
        checksum: f572d396fae9206628714fb2ce00f72e94f2258f
        force: false
    - name: This does not actually make sure greeting.txt has the expected checksum
        win_get_url:
        url: https://otherplace.example.invalid/~kbj/tmp/hei.txt
        dest: C:/Windows/Temp/greeting.txt
        checksum: b7a7bf03dcafd4d48001d6a2a6fd2ceaefa4cc1e
        force: false

This is obviously a contrived example, but replace dest with SomeSoftware.zip and the URLs by download URLs for SomeSoftware-1.2.3.zip and SomeSoftware-1.3.0.zip and you get different behaviour on hosts depending on if they downloaded version 1.2.3 before or after 1.3.0 was released.

@KBjorndal-VizRT
Copy link
Author

I'll try to come up with a PR to improve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant