-
Notifications
You must be signed in to change notification settings - Fork 152
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
Fixing untar on Windows #172
Conversation
Codecov Report
@@ Coverage Diff @@
## master #172 +/- ##
==========================================
- Coverage 91.82% 91.74% -0.08%
==========================================
Files 29 29
Lines 1871 2047 +176
==========================================
+ Hits 1718 1878 +160
- Misses 153 169 +16
Continue to review full report at Codecov.
|
It seems like I cannot suppress the output from |
@jimhester I think this is good now. |
R/utils.R
Outdated
@@ -157,17 +157,31 @@ with_rprofile_user <- function(new, code) { | |||
|
|||
untar <- function(tarfile, ...) { | |||
if (os_type() == "windows") { | |||
status <- try(utils::untar(tarfile, extras = "--force-local", ...)) | |||
if(inherits(status, "try-error") || status != 0){ | |||
tarhelp <- system2("tar", "--help", stdout = TRUE, stderr = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Sys.getenv("TAR")
is 'internal' we should probably just skip this completely. Also what does system2()
do if there is no tar executable on the PATH?
OTOH extras
is ignored if using the internal tar implementation IIRC, so maybe it is fine as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah, system2
needs to be tryCatch()
-ed. Thanks for catching this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
R/utils.R
Outdated
silent = TRUE) | ||
if (inherits(status, "try-error") || | ||
is_error_status(status) || is_error_status(attr(status, "status"))) { | ||
message("External tar failed with `--force-local`, trying without") | ||
utils::untar(tarfile, ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three cases that all end with utils::untar(tarfile, ...)
. So we should be able to rewrite the case that returns the status with an early return and have the rest of the cases fall through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but it was actually less readable than the current code. You cannot mark "not done yet" with status = NULL
, because maybe that's a legit return value. Do you need a done
variable, plus status
... anyway, I'll give it another try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better now, I think.
@jimhester done. tested on win, and CI passed as well |
R/utils.R
Outdated
silent = TRUE) | ||
if (! inherits(status, "try-error") && | ||
! is_error_status(status) && | ||
!is_error_status(attr(status, "status"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just roll these all into is_error_status()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, much easier to read now, thanks!
Thanks! |
utils::untar()
callssystem()
withintern = TRUE
,so we need to check for
attr(status, "status")
as well.In addition we silence the first
try()
, and give anexplicit message about retrying instead. See also #151.
Closes #171.