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

Refactor use_course() and gain progress reporting #380

Merged
merged 4 commits into from Jun 1, 2018

Conversation

Projects
None yet
3 participants
@jennybc
Member

jennybc commented Jun 1, 2018

Fixes #276 Refactor use_course()

Thanks @jeroen for all the pointers!

Key things:

  • Explicit use of a handle is how we hook into progress
    reporting, even though curl_download() doesn't expose
  • curl_download() has a built-in check for http status 200
  • Using a custom progressfunction because default doesn't
    always look right in RStudio
  • Switch to fs functions for file system work
Refactor use_course() and gain progress reporting
Fixes #276

Thanks @jeroen for all the pointers!

Key things:

  * Explicit use of a handle is how we hook into progress
    reporting, even though curl_download() doesn't expose
  * curl_download() has a built-in check for http status 200
  * Using a custom progressfunction because default doesn't
    always look right in RStudio
  * Switch to fs functions for file system work
@jennybc

This comment has been minimized.

Show comment
Hide comment
@jennybc

jennybc Jun 1, 2018

Member

Quick screenshot snagged while downloading some hefty course materials from @hadley

screen shot 2018-06-01 at 2 22 31 pm

This updates in place during the download.

Member

jennybc commented Jun 1, 2018

Quick screenshot snagged while downloading some hefty course materials from @hadley

screen shot 2018-06-01 at 2 22 31 pm

This updates in place during the download.

Show outdated Hide outdated R/course.R
@@ -328,6 +331,19 @@ parse_content_disposition <- function(cd) {
)
}
progress_fun <- function(down, up) {

This comment has been minimized.

@jennybc

jennybc Jun 1, 2018

Member

The default curl progress bar gets mangled in (some versions of?) RStudio, so I took @jeroen's advice to copy an approach from tesseract.

https://github.com/ropensci/tesseract/blob/6514c5862a6e6991c45048449b20fd24babf4bb4/R/tessdata.R#L63-L74

@jennybc

jennybc Jun 1, 2018

Member

The default curl progress bar gets mangled in (some versions of?) RStudio, so I took @jeroen's advice to copy an approach from tesseract.

https://github.com/ropensci/tesseract/blob/6514c5862a6e6991c45048449b20fd24babf4bb4/R/tessdata.R#L63-L74

@jennybc jennybc requested a review from hadley Jun 1, 2018

@jennybc

This comment has been minimized.

Show comment
Hide comment
@jennybc

jennybc Jun 1, 2018

Member

@jeroen I can't formally request a review from you and I think I followed your advice fairly faithfully, but feel free to comment.

Member

jennybc commented Jun 1, 2018

@jeroen I can't formally request a review from you and I think I followed your advice fairly faithfully, but feel free to comment.

@jeroen

This comment has been minimized.

Show comment
Hide comment
@jeroen

jeroen Jun 1, 2018

Member

Yes I like it, nice how it saves it under the server suggested filename. Maybe somewhere insert a cat("\n") after the download has finished to print the message to a new line?

screen shot 2018-06-01 at 11 37 43 pm

Member

jeroen commented Jun 1, 2018

Yes I like it, nice how it saves it under the server suggested filename. Maybe somewhere insert a cat("\n") after the download has finished to print the message to a new line?

screen shot 2018-06-01 at 11 37 43 pm

@hadley

hadley approved these changes Jun 1, 2018

Show outdated Hide outdated R/course.R
Show outdated Hide outdated R/course.R

jennybc added some commits Jun 1, 2018

@jennybc jennybc merged commit fdfcfd7 into master Jun 1, 2018

0 of 4 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@jennybc jennybc deleted the use-course-progress branch Jun 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment