diff --git a/R/candidatos_nosenado.R b/R/candidatos_nosenado.R index 85032c3..a7406e6 100644 --- a/R/candidatos_nosenado.R +++ b/R/candidatos_nosenado.R @@ -94,7 +94,7 @@ candidatos_nosenado <- function(tipo, anno, mes) { df$nacimiento <- NA df$dni <- NA - cleanup(temp, tempd) + cleanup(tempd) return(df) } diff --git a/R/cleanup.R b/R/cleanup.R index f8cfc9d..80ca64f 100644 --- a/R/cleanup.R +++ b/R/cleanup.R @@ -1,13 +1,11 @@ #' @title Cleans up the files and directories created during the process #' -#' @param files The files to remove. #' @param dirs The directories to remove. #' #' @return NULL #' #' @keywords internal #' -cleanup <- function(files, dirs) { - # file.remove(files) +cleanup <- function(dirs) { unlink(dirs, recursive=TRUE) } diff --git a/R/download_bin.R b/R/download_bin.R index 4415544..fdc6f32 100644 --- a/R/download_bin.R +++ b/R/download_bin.R @@ -16,13 +16,14 @@ download_bin <- function(url, tempfile) { "Gecko/20100101 Firefox/98.0" ) - if(file.exists(tempfile)) { - message("File already exists, skipping download") + if (file.exists(tempfile)) { + message( + "File already exists, skipping download. Reading existing file ", + gsub("..+/", "", tempfile) + ) } else { message("Downloading ", url) res <- GET(url, add_headers(`User-Agent` = UA, Connection = "keep-alive")) writeBin(res$content, tempfile) } - - } diff --git a/R/mesas.R b/R/mesas.R index 00c1836..37c0d81 100644 --- a/R/mesas.R +++ b/R/mesas.R @@ -99,7 +99,7 @@ mesas <- function(tipo_eleccion, anno, mes) { df$municipio[df$codigo_municipio == "999"] <- "CERA" - cleanup(temp, tempd) + cleanup(tempd) return(df) } diff --git a/R/muni.R b/R/muni.R index 98d91aa..cf4c8de 100644 --- a/R/muni.R +++ b/R/muni.R @@ -111,7 +111,7 @@ municipios <- function(tipo_eleccion, anno, mes, distritos = FALSE) { df <- unique(df[df$codigo_distrito == 99, ]) } - cleanup(temp, tempd) + cleanup(tempd) return(df) } diff --git a/R/provincias.R b/R/provincias.R index 33ff46a..39df8c3 100644 --- a/R/provincias.R +++ b/R/provincias.R @@ -96,7 +96,7 @@ provincias <- function(tipo_eleccion, anno, mes) { desc("votos") ) - cleanup(temp, tempd) + cleanup(tempd) return(df) } diff --git a/R/senado_mesas.R b/R/senado_mesas.R index 5459851..46a3e5d 100644 --- a/R/senado_mesas.R +++ b/R/senado_mesas.R @@ -128,7 +128,7 @@ senado_mesas <- function(anno, mes) { df$nacimiento[df$nacimiento_anno == "0000"] <- NA - cleanup(temp, tempd) + cleanup(tempd) return(df) } diff --git a/R/senado_municipios.R b/R/senado_municipios.R index 402f718..62ad15c 100644 --- a/R/senado_municipios.R +++ b/R/senado_municipios.R @@ -125,7 +125,7 @@ senado_municipios <- function(anno, mes) { df$nacimiento[df$nacimiento_anno == "0000"] <- NA - cleanup(temp, tempd) + cleanup(tempd) return(df) } diff --git a/man/cleanup.Rd b/man/cleanup.Rd index c4cf43a..924dd74 100644 --- a/man/cleanup.Rd +++ b/man/cleanup.Rd @@ -4,11 +4,9 @@ \alias{cleanup} \title{Cleans up the files and directories created during the process} \usage{ -cleanup(files, dirs) +cleanup(dirs) } \arguments{ -\item{files}{The files to remove.} - \item{dirs}{The directories to remove.} } \description{