Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmckay committed Sep 3, 2024
1 parent a6c4847 commit e38a261
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/directory.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ get_src_or_dst<- function(path){
if(!any("datasetId" %in% names(path))){
stop("To use a data.frame as input, one of the columns must be named 'datasetId' and include datasetIds from the LiPDverse.")
}
path <- c(path$datasetId)
if(any("datasetVersion" %in% names(path))){
vers <- c(path$datasetVersion)
vers <- c(path$datasetVersion) |> str_replace_all("\\.","_")
}else{
vers <- rep(NA,length(path))
}
path <- c(path$datasetId)
}
if(length(path) > 1){
if(!all(purrr::map_lgl(path,~ tools::file_ext(.x) == "lpd"))){
Expand Down
16 changes: 15 additions & 1 deletion R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,21 @@ download_from_url <- function(path){
dir.create(dir)
local_path <- file.path(dir, paste0(basename(dirname(dirname(path))), ".lpd"))
print(glue::glue("Downloading {length(path)} datasets from lipdverse.org..."))
purrr::walk2(path,local_path,purrr::possibly(download.file),method = dmeth,quiet = TRUE,otherwise = NULL)
purrr::walk2(path,
local_path,
purrr::possibly(download.file,otherwise = NA),
method = dmeth,
quiet = TRUE,
.progress = TRUE)

#check for consistency
downloadedFiles <- list.files(unique(dirname(local_path)),full.names = TRUE)
diffFiles <- setdiff(local_path,downloadedFiles)
if(length(diffFiles) > 0){
cat(crayon::bold(crayon::red(glue::glue('{length(diffFiles)} datasets failed to download. You are missing the following datasetIds: \n{paste0(basename(stripExtension(diffFiles)),collapse = ";\n")}'))))
cat("\n\n")
}

path <- dir
}else if(all(!isUrl)){
path <- path
Expand Down

0 comments on commit e38a261

Please sign in to comment.