Skip to content

Commit

Permalink
Merge pull request #28 from OldLipe/b-0.9.0
Browse files Browse the repository at this point in the history
fix assets_download extensions name bug (closes #27)
  • Loading branch information
gqueiroz authored Mar 24, 2021
2 parents ef0819d + 7c5aa8c commit edfa178
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
image: brazildatacube/r-webservices:1.0.0
commands:
- R CMD build .
- set -e; R CMD check *.tar.gz >&1 | tee stdfile && cat stdfile | (grep -E "(WARNING)" > /dev/null) && exit 1 || exit 0
- set -e; R CMD check *.tar.gz >&1 | tee stdfile && cat stdfile | (grep -E "(WARNING|ERROR)" > /dev/null) && exit 1 || exit 0

- name: coverage
image: brazildatacube/r-webservices:1.0.0
Expand Down
16 changes: 12 additions & 4 deletions R/assets_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@
#' the link of the item pointing to the directory where the assets were saved.
#'
#' @export
assets_download <- function(items, assets_name, output_dir = ".",
overwrite = FALSE, items_max = Inf, progress = TRUE,
assets_download <- function(items,
assets_name,
output_dir = ".",
overwrite = FALSE,
items_max = Inf,
progress = TRUE,
...) {

#check the object subclass
Expand Down Expand Up @@ -95,8 +99,9 @@ assets_download <- function(items, assets_name, output_dir = ".",
utils::setTxtProgressBar(pb, i)

items$features[[i]] <- .item_download(items$features[[i]],
assets_name, output_dir,
overwrite,...)
assets_name,
output_dir,
overwrite, ...)
}
# close progress bar
if (progress)
Expand Down Expand Up @@ -173,6 +178,9 @@ assets_download <- function(items, assets_name, output_dir = ".",
#' @noRd
.file_ext <- function(asset_url) {

# remove query string from url
asset_url[[1]] <- sub("\\?.+", "", asset_url[[1]])

pos <- regexpr("\\.([[:alnum:]]+)$", asset_url[[1]])
if (pos < 0) return("")
return(substring(asset_url[[1]], pos + 1))
Expand Down

0 comments on commit edfa178

Please sign in to comment.