Skip to content

Commit

Permalink
Squashes bugs related to caching
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhsparks committed Nov 19, 2024
1 parent 2fcddbf commit a7a41aa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions R/get_abares_trade_regions.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
get_abares_trade_regions <- function(cache = TRUE) {
trade_regions <- .check_existing_trade_regions(cache)
if (!is.null(trade_regions)) {
return(trade_regions)
return(trade_regions[])
} else {
return(.download_abares_trade_regions(cache))
}
Expand All @@ -47,19 +47,19 @@ get_abares_trade_regions <- function(cache = TRUE) {
.check_existing_trade_regions <- function(cache) {
abares_trade_rds <- file.path(.find_user_cache(),
"abares_trade_dir/abares_trade_regions.rds")
tmp_csv <- file.path(tempdir(), "abares_trade_regions.csv")
tmp_zip <- file.path(tempdir(), "abares_trade.zip")

if (file.exists(abares_trade_rds)) {
return(readRDS(abares_trade_rds))
} else if (file.exists(tmp_csv)) {
abares_trade <- data.table::fread(tmp_csv,
} else if (file.exists(tmp_zip)) {
abares_trade <- data.table::fread(tmp_zip,
na.strings = c(""),
fill = TRUE)
if (cache) {
dir.create(dirname(abares_trade_rds), recursive = TRUE)
saveRDS(abares_trade, file = abares_trade_rds)
}
return(abares_trade)
return(abares_trade[])
} else {
return(NULL)
}
Expand Down Expand Up @@ -110,5 +110,5 @@ get_abares_trade_regions <- function(cache = TRUE) {
file.path(abares_trade_dir, "abares_trade_regions.csv")
))
}
return(abares_trade_regions)
return(abares_trade_regions[])
}
3 changes: 1 addition & 2 deletions R/get_estimates_by_size.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


#' Get Estimates by Size From ABARES
#'
#' @note
Expand Down Expand Up @@ -31,7 +30,7 @@ get_estimates_by_size <- get_est_by_size <- function() {
neworder = c("Variable", "Year", "Size", "Industry", "Value", "RSE"))
data.table::setkey(x, "Variable")

return(x)
return(x[])
}

#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/get_soil_thickness.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ get_soil_thickness <- function(cache = TRUE) {
download_dir <- dirname(download_file)

# this is where the zip files are unzipped in `soil_thick_dir`
soil_thick_adf_file <- file.path(download_dir, "soil_thickness_dir")
soil_thick_adf_file <- file.path(download_dir, "soil_thickness_dir/thpk_1")

# only download if the files aren't already local
if (!file.exists(soil_thick_adf_file)) {
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
},
"SystemRequirements": null
},
"fileSize": "330.587KB",
"fileSize": "330.574KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down

0 comments on commit a7a41aa

Please sign in to comment.