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

download command to download without installing/expanding #121

Merged
merged 3 commits into from
Dec 31, 2020

Conversation

art-divin
Copy link
Contributor

@art-divin art-divin commented Nov 23, 2020

Closes #112

Sometimes it's useful to just download Xcode xip without expanding it.
The implemented solution shows progress as:
xcodes download 12.0 (1/1) Downloading Xcode 12.0.0: 5 %
where 1/6 step indicator is replaced by 1/1 depending on the used command (install vs. download)

When the download is finished, the following message appears:
Xcode 12.0.0 has been downloaded to /Users/<#redacted#>/Library/Application Support/com.robotsandpencils.xcodes/Xcode-12.0.0.xip

Flags and arguments are exactly as in "install" command, as such the actual code that creates "install" command is reused for both "download" and "install", and depending on the "shouldInstall" flag, one of two is created with appropriate --help configuration and other strings.

@art-divin art-divin changed the title Added download command to download without installing/expanding download command to download without installing/expanding Nov 23, 2020
@interstateone
Copy link
Contributor

Thanks for this PR too! This'll be great to have, and I think xcodes download is more straightforward than xcodes install --no-install as I'd described in the issue.

I'd prefer to have this download command save the XIP to a path that the user provides, such as with a --destination flag, so that the application support directory isn't a place the user needs to know about. This is related to #100, and I have some work in progress to implement this locally that I'll try to finish up soon. I don't think that work necessarily needs to prevent merging this PR, so I may make a few changes after merging this and before releasing a new version.

Just wanted to let you know that I've seen and appreciate this PR, and it may take a bit more time to review and merge it. Thanks @art-divin.

@art-divin
Copy link
Contributor Author

xcodes download is more straightforward than xcodes install --no-install
Could not agree more! I already use this option a lot.

I may make a few changes after merging this and before releasing a new version
Sounds just great! You can open more issues if you have something in mind you can delegate, they may be related to what I am up to.

I am also implementing option to allow xcodes download 12.0 --remove to support clean up, as well as xcodes download --clear-cache or similar naming - to remove all of the downloaded xips that are within xcodes' app container.

Later (this week will be delivered) I will be implementing commands such as xcodes unxip (already in progress), xcodes undmg (currently dmg is unsupported), xcodes finder 12.1 (open directory containing the downloaded xip / unxipped .app of the specified version) and maybe some more. FYI I will be doing this myself anyways, they will be used in my current project. I will be creating PRs so you are free to merge them whenever you'd like!

I appreciate your feedback, though, don't waste time thanking me, we all are beneficiaries anyways 😄

@interstateone
Copy link
Contributor

Hmm, those commands don't sound like something I'd considered before. Could you tell me more about the problem you're solving and how you're planning on using them?

@art-divin
Copy link
Contributor Author

art-divin commented Nov 24, 2020

Could you tell me more about the problem you're solving and how you're planning on using them?

Ha thanks for your interest! 😅
Unfortunately this project needs to be properly finished before I can tell, but you can be sure there’s going to be your mention in 3rd-party licenses section!

@art-divin
Copy link
Contributor Author

art-divin commented Nov 29, 2020

I've discovered that --path is not taken into account when using the new download command. The reason is that in the old version, install command was using the provided --path as an input for the actual downloaded xip file. However, w/ the case of download command, that argument needs to be taken as a destination of the downloaded file to be moved in both URLSession and aria2 variants.
I've fixed this in my fork, but I need to cherry-pick changes to this branch before I'll be able to commit. So, fix is coming!

Also, there's an issue w/ URLSession option. The cache can become both invalid and large in size if there'd be multiple attempts of download w/ NSURLSessionDownloadTask. There's no way to specify URL for the cache files, they are put in /private/var/folders/... (Which is eventually gets cleaned by the system under some specific conditions, but there's no manual control over it as far as I am concerned.). Compared to aria2 option, which creates cache file in the same dir as where the final destination is.

@art-divin
Copy link
Contributor Author

OK, added support for --path flag, so
xcodes download --path ~/Downloads/xcodes/something.xip would move file (downloaded by NSURLSession) into the --path directory,
the same for --aria2 option, except that cache for --aria2 would also be placed inside of that destination directory

@ccarpita
Copy link
Contributor

pr-great-interest

adjusted progress reporting for when download only

fixed missing replacement

added support for --path flag

fixed failing test

fixed failing test x2
@interstateone
Copy link
Contributor

Thanks for your patience @art-divin, I'm taking another look at this now. I'm going to rebase it on master and make a few changes.

I'm going to rename the path argument to directory, which will match the argument name in my implementation of #100, and also avoids confusion of a path to the directory and a full path to the .xip.

I'm also going to set a default value for directory of ~/Downloads and move the .xip there, as I don't think the application support directory should be exposed to the user.


Also, there's an issue w/ URLSession option. The cache can become both invalid and large in size if there'd be multiple attempts of download w/ NSURLSessionDownloadTask. There's no way to specify URL for the cache files, they are put in /private/var/folders/... (Which is eventually gets cleaned by the system under some specific conditions, but there's no manual control over it as far as I am concerned.). Compared to aria2 option, which creates cache file in the same dir as where the final destination is.

I think this behaviour is fine for xcodes' purposes, unless there's a particular reason you think the in-progress download data should be handled differently?


Thanks for the contribution!

@interstateone interstateone merged commit 1478a34 into XcodesOrg:master Dec 31, 2020
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 this pull request may close these issues.

Allow downloading XIP without installing
3 participants