wangyuchen opened a new issue #7058:
URL: https://github.com/apache/arrow/issues/7058


   
https://github.com/apache/arrow/blob/d1f757339c24ff06e1d39f878323878be64e0369/r/tools/linuxlibs.R#L39-L47
   
   
   I think there might be a bug in this utility function. In the installation 
script for Linux, it uses this function to try to download things and capture 
if download is successful. However, a `tempfile()` is always created *before* 
the attempt to download, and the tempfile path is passed to the `to_file` 
argument. 
   
   This behaves as expected when  `libcurl` method is used for downloading 
files. But with `wget` or `curl`, when the download is unsuccessful, the file 
would still exist, so `file.exist()` will still return `TRUE`, as if the 
download is successful. This potentially can guide the installation on the 
wrong path. 
   
   Reprex:
   
   ``` r
   base_url <- "https://dl.bintray.com/ursalabs/arrow-r/libarrow/bin/centos-7/";
   wrong_file <- "arrow-999999.zip"
   
   quietly <- FALSE
   
   try_download <- function(from_url, to_file) { 
     try( 
       suppressWarnings( 
         download.file(from_url, to_file, quiet = quietly) 
       ), 
       silent = quietly 
     ) 
     file.exists(to_file) 
   } 
   
   options(download.file.method = "curl")
   
   try_download(paste0(base_url, wrong_file), tempfile())
   #> [1] TRUE
   
   options(download.file.method = "wget")
   
   try_download(paste0(base_url, wrong_file), tempfile())
   #> Error in download.file(from_url, to_file, quiet = quietly) : 
   #>   'wget' call had nonzero exit status
   #> [1] TRUE
   
   options(download.file.method = "libcurl")
   
   try_download(paste0(base_url, wrong_file), tempfile())
   #> Error in download.file(from_url, to_file, quiet = quietly) : 
   #>   cannot open URL 
'https://dl.bintray.com/ursalabs/arrow-r/libarrow/bin/centos-7/arrow-999999.zip'
   #> [1] FALSE
   ```
   
   <sup>Created on 2020-04-28 by the [reprex 
package](https://reprex.tidyverse.org) (v0.3.0)</sup>
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to