-
Notifications
You must be signed in to change notification settings - Fork 70
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
Parse Github Asset Based on Accessibility #77
base: master
Are you sure you want to change the base?
Conversation
For supporting private releases, the ReleaseAsset parsing function was changed to use a different field in the JSON document, namely from browser_download_url -> url. This change breaks the download of assets for public Releases, as those still use the previous field. You can see this in the documentation for the API: https://docs.github.com/en/rest/reference/repos#releases On a public release, the 'url' field on the asset doesn't return the download location for the asset, so the download_url for the ReleaseAsset struct isn't set correctly. This change introduces an 'is_private' parameter on the from_asset function set the field based on whether the release is private or not. It's determined to be private based on whether an auth token has been specified.
@jacderida Thanks for pointing this out. I see what you're saying, and I see that running the github example says it's going to download from the "asset" url instead of from the actual "download" url e.g.
And then curling that url directly just returns json
Now.. what's baffling me is that the github example still "works"... when I run it, it does download the actual release, unpackages it, and overwrites my |
Hmm, that's strange indeed. I'm honestly not sure. What we were seeing was the JSON document being downloaded rather than the actual asset. To be honest, I did want to do some more testing before I submitted the PR to you. The commit where the field was changed from I didn't get time to validate that assumption, though. I guess it's possible that GIthub maybe changed the field at some point, but they changed it back again? We are trying to publish one of our crates that use this one and right now it's using a git reference for this dependency which contains my fix. So I just didn't quite have time to do any more elaborate testing, sorry. |
Ah, I see why it's working - when you send an
And the request here just happens to automatically set an accept header: Line 678 in af699de
(I added a couple printlns to check if there were any other headers being sent):
So I think the simpler move would be to explicitly add an |
OK, thanks. However, I'm not quite sure what the way forward is here. Would you like me to close this PR and open another one? Or were you going to make that change? |
Either or - You could do it here or in a new PR, up to you |
Sorry for taking so long to get back to you. Lots of work got in the way. I was just about to address this. If I understand you correctly, you're asking me to change the code to add the However, this is already being done here: https://github.com/jaemk/self_update/blob/master/src/update.rs#L217 It also shows that header as set in the output on your post. I think I've possibly misunderstood something. Could you advise please? |
hm, yeah sorry I missed that - guess everything's all set already |
Given we still experience the problem with the incorrect URL, where does that leave us? |
Interesting. Can you confirm (or share a link to your release) whether |
Sorry for taking some time to get back to you. So I found the problem. We had been using your crate not just for updating the current crate, but also for downloading assets from releases for other crates. Here's the code we were using:
So the problem was, the I personally think it would be a better API if this header was set in |
Ah, I see. Yes, I agree that it would be better if the header was set automatically. Could you make that change here or in a new PR? |
For supporting private releases, the ReleaseAsset parsing function was changed to use a different field in the JSON document, namely from browser_download_url -> url. This change breaks the download of assets for public Releases, as those still use the previous field.
You can see this in the documentation for the API: https://docs.github.com/en/rest/reference/repos#releases
On a public release, the 'url' field on the asset doesn't return the download location for the asset, so the download_url for the
ReleaseAsset struct isn't set correctly.
This change introduces an
is_private
parameter on thefrom_asset
function set the field based on whether the release is private or not. It's determined to be private based on whether an auth token has been specified.