xcpretty / xcode-install

🔽 Install and update your Xcodes
https://fastlane.tools
MIT License
2.58k stars 237 forks source link

Add --retry-download-count for retrying installing Xcode xip/dmg #400

Closed freddi-kit closed 3 years ago

freddi-kit commented 3 years ago

Issue

Related: https://github.com/xcpretty/xcode-install/issues/345

Abstract

Add --retry-download-count for xcversion install command to retry install again

$ xcversion install 11.7  --retry-download-count=5

Motivation

As mentioned https://github.com/xcpretty/xcode-install/issues/345, some user has an issue to download such big Xcode application. We can re-use this on-the-way result to re-try downloading.

However, retry is limited to 3 times even if the cache is available and it can be used by retrying.

# Line 81 at lib/xcode/install.rb 
3.times do
...

After 3-times, we have to call xcversion again to continue by hand on terminal.

Strategy

So I added --retry-download-count, to retry download automatically. This would help to solve the mentioned issue.

$ xcversion install 11.7  --retry-download-count=5

Note

If invalid arg such kind of -1 and "string", it will be error

$ xcversion install 11.7  --retry-download-count=xcode
[!] Invalid Retry: `xcode is not positive number.`
freddi-kit commented 3 years ago

Thank you!

freddi-kit commented 3 years ago

When is this included to new version?

jpsim commented 3 years ago

I don't know, I don't have access to push new versions to rubygems.

freddi-kit commented 3 years ago

okay, I wish it will be delivered soon. thank you for merging it

pronebird commented 3 years ago

Would it make sense to not count errors when the curl reports that more data is left to read? For example:

curl: (18) transfer closed with 9327120816 bytes remaining to read

There is obviously 9327120816 bytes more to read, so can this be taken into account somehow? It makes total sense to continue the download instead of failing.

freddi-kit commented 3 years ago

I think it would be better, but I think we need some string parser to get byte from the error message. And not sure the error message is stable or not on each curl version.

pronebird commented 3 years ago

@freddi-kit aha so there is no back channel from curl, like exit code or something?

freddi-kit commented 3 years ago

@pronebird Ah, maybe we can use exit code, let me check it after https://github.com/xcpretty/xcode-install/pull/405 is merged