I decided to add the behaviour "use filename from original request, which could make a difference when redirects are followed" to #downloadTo: while #downloadEntityTo: remains unchanged (not that it could change because the original request is gone by then). In Zn #bleedingEdge: === Name: Zinc-HTTP-SvenVanCaekenberghe.443 Author: SvenVanCaekenberghe Time: 4 December 2015, 3:26:34.596347 pm UUID: 967114b0-e87f-4c5e-a511-d31efc27acae Ancestors: Zinc-HTTP-SvenVanCaekenberghe.442 Change ZnClient>>#downloadTo: to use the original request's URI for the basename to download to (this could make a difference when redirects are followed) Add comments to make this difference between #downloadTo: and #downloadEntityTo: clear === As for the overwriting of an existing file, if you load === Name: Zinc-FileSystem-SvenVanCaekenberghe.12 Author: SvenVanCaekenberghe Time: 4 December 2015, 3:23:41.83904 pm UUID: 66adef8d-edfb-49e1-aa33-f464ae2ca28f Ancestors: Zinc-FileSystem-SvenVanCaekenberghe.11 Use proper resumable exceptions, FileExits and FileDoes NotExit, in ZnFileSystemUtils === You can now do as follows: [ ZnClient new url: 'https://github.com/kilon/ChronosManager/archive/master.zip'; downloadTo: FileLocator imageDirectory; yourself ] on: FileExists do: [ :exception | exception resume ] HTH, Sven
On 04 Dec 2015, at 11:56, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
"Thanks for the feedback."
Thanks for this very useful library :)
"Hmm, that is tricky. If you inspect ZnLogEvent announcer during the execution you will notice that a redirect is involved. Your original request for https://github.com/kilon/ChronosManager/archive/master.zip gets redirected to a request for https://codeload.github.com/kilon/ChronosManager/zip/master for which the name is effectively 'master' without the extension. Maybe the original name should be used, I have to think a bit about that. It seems that curl does it like that."
naughty Github
but I am curious is it not normal for a dowload link to redirect to something else anyway ? I have seen such redirections frequently with browser.
"ZnClient new url: 'https://github.com/kilon/ChronosManager/archive/master.zip'; setIfModifiedSince: (Date year: 2015 month: 12 day: 1); downloadTo: FileLocator imageDirectory / 'master.zip'; yourself."
yes that though crossed my mind too.
How I tell ZnClient to overwrite an existing file , because by default it complains and pops up a dialog.
"Yeah, not much you can do about that."
Well I could have gone with the Github api in the first place , as Skip notedm but I am clueless when it comes to web dev.
" The API supports conditional requests (If-Modified-Since and If-None-Match), so perhaps you should use the API endpoints:
https://developer.github.com/v3/#conditional-requests"
because I am clueless with web dev can you help me understand how to do this with ZnClient ?
Is this what people are referring to as a REST API ?
" I am planning to implement caching and conditional requests in my API bindings:
https://github.com/Balletie/GitHub "
your tool is great but i am trying to create as few dependencies for my project as possible or else it will take forever to load in a pharo image but I am definitely interesting into learning from your code . Thanks :)