googledrive icon indicating copy to clipboard operation
googledrive copied to clipboard

error while downloading files that contain `'` (apostrophe) in the filename

Open cmzambranat opened this issue 3 years ago • 1 comments

Hello! I'm facing an error when downloading files containing '. For example, the file WHO_Cote d'Ivoire will fail with:

Error in glue_data(.x = NULL, ..., .sep = .sep, .envir = .envir, .open = .open, : Unterminated quote (')

If I remove the ' from the filename (i.e. WHO_Cote dIvoire), the function drive_download works fine. This might be related to #397.

cmzambranat avatar Aug 12 '22 03:08 cmzambranat

I'm experiencing the same issue.

If I attempt to download the file as a file id and turn off verbosity, I can continue on. (Note that the 'verbose' argument of drive_download is deprecated.) Perhaps the issue is in printing the file name to console using glue_data()?

This works:

download_file2 <- function(id, drive_resource, years, sub_dir, ...){
  drive_download(
    as_id(id),      
    paste0("../", years, "/", sub_dir, "/", id, ".xlsx"),
    verbose = FALSE)
} 

walk(list_q, ~download_file2(.x$id, .x$drive_resource, years = "2021_2022", sub_dir = "q"))

This does not:

download_file <- function(id, drive_resource, years, sub_dir, ...){
  drive_download(
    as_id(id),      
    paste0("../", years, "/", sub_dir, "/", id, ".xlsx"),
    verbose = TRUE)
} 

walk(list_q, ~download_file(.x$id, .x$drive_resource, years = "2021_2022", sub_dir = "q"))

millerjef avatar Aug 19 '22 20:08 millerjef

I'm fairly sure this error was actually from emitting a message, as suggested by @millerjef, and not from drive_download() (although that is not at all obvious). In the meantime, the root case has been fixed in cli (probably in https://github.com/r-lib/cli/commit/725766d9e27e09c62a94beefce322bd453134866). I can download a file whose name contains ' now.

jennybc avatar Mar 20 '23 04:03 jennybc