Skip to content

Commit

Permalink
fixing linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Haydée Svab committed Nov 18, 2023
1 parent e4f643a commit 23ecd67
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 6 additions & 9 deletions R/download_piggyback.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#' @keywords internal
download_piggyback <- function(filename_to_download,
force_download = FALSE) {

# Defining our temporary directory
temp_dest_dir <- tempdir(check = TRUE)

Expand All @@ -21,10 +20,10 @@ download_piggyback <- function(filename_to_download,
temp_full_file_path <- paste0(temp_dest_dir, "/", filename_to_download)

if (!file.exists(temp_full_file_path) || force_download) {

# downloading the file from a release of the odbr repo - release specified in the parameter
try(silent = TRUE,
piggyback::pb_download(
try(
silent = TRUE,
piggyback::pb_download(
file = filename_to_download,
repo = "hsvab/odbr",
dest = temp_dest_dir
Expand All @@ -33,13 +32,11 @@ download_piggyback <- function(filename_to_download,
}

# Halt function if download failed
if (!file.exists(temp_full_file_path) ) {
message('Internet connection not working properly.')
if (!file.exists(temp_full_file_path)) {
message("Internet connection not working properly.")
return(invisible(NULL))

} else {
# return string with the path to the file saved in a tempdir
# return string with the path to the file saved in a tempdir
return(temp_full_file_path)
}

}
4 changes: 3 additions & 1 deletion R/read_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ read_map <- function(city = "S\u00E3o Paulo",
temporary_filename <- download_piggyback(filename_to_download, force_download)

# check if download worked
if(is.null(temporary_filename)) { return(NULL) }
if (is.null(temporary_filename)) {
return(NULL)
}

# Reading shape files
od_map <- sf::read_sf(temporary_filename)
Expand Down
4 changes: 3 additions & 1 deletion R/read_od.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ read_od <- function(city = "S\u00E3o Paulo",
temporary_filename <- download_piggyback(filename_to_download, force_download)

# check if download worked
if(is.null(temporary_filename)) { return(NULL) }
if (is.null(temporary_filename)) {
return(NULL)
}

# Reading the file to a release in odbr repository
od_file <- data.table::fread(temporary_filename,
Expand Down

0 comments on commit 23ecd67

Please sign in to comment.