Skip to content

Commit

Permalink
changes search_for_newer_data
Browse files Browse the repository at this point in the history
fixes #46
  • Loading branch information
DanChaltiel committed Jul 25, 2024
1 parent 855ea15 commit a9dabcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions R/search_for_newer_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param source the path vector to be searched, default to both "data" and the usual "Downloads" folder
#' @param target the path where files should be copied
#' @param ask whether to ask the user to move the file to "data"
#' @param advice whether to advice how to move it, if `ask==FALSE`
#' @param advice whether to advice how to move it instead, if `ask==FALSE`
#'
#' @return the path to the newer file, invisibly.
#' @export
Expand All @@ -22,19 +22,20 @@
#'
#' }
search_for_newer_data = function(archive, ...,
source=c("data", path_home("Downloads")),
source=path_home("Downloads"),
target="data",
ask=TRUE, advice=TRUE){
check_dots_empty()
assert(length(target)==1)
project_name = parse_file_projname(archive)
project_date = parse_file_datetime(archive)

if(any(!dir_exists(source))){
source_bad = source[!dir_exists(source)]
cli_warn(c("{.arg source} contains nonexistent directories: {.val {source_bad}}."))
if(all(!dir_exists(setdiff(source, target)))){
cli_abort(c("{.arg source} contains only nonexistent directories."))
source = source[dir_exists(source)]
}
source = c(target, source)

files = dir_ls(source, type="file", fail=FALSE,
regexp=glue(".*{project_name}.*\\.zip"))
if(length(files)==0){
Expand Down
2 changes: 1 addition & 1 deletion man/search_for_newer_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a9dabcc

Please sign in to comment.