-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dataDWD: force can now be number of hours after which to re-download
- Loading branch information
Showing
4 changed files
with
14 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,9 @@ | |
#' Created if not existent. DEFAULT: "DWDdata" at current \code{\link{getwd}()} | ||
#' @param force Logical (vector): always download, even if the file already exists in \code{dir}? | ||
#' Use NA to force re-downloading files older than 24 hours. | ||
#' If FALSE, it is still read (or name returned). DEFAULT: FALSE | ||
#' Use a numerical value to force after that amount of hours. | ||
#' Note you might want to set \code{overwrite=TRUE} as well. | ||
#' If FALSE, the file is still read (or name returned). DEFAULT: FALSE | ||
#' @param overwrite Logical (vector): if force=TRUE, overwrite the existing file | ||
#' rather than append "_1"/"_2" etc to the filename? DEFAULT: FALSE | ||
#' @param sleep Number. If not 0, a random number of seconds between 0 and | ||
|
@@ -150,10 +152,14 @@ outfile <- gsub(paste0(base,"/"), "", file) | |
outfile <- gsub("/", "_", outfile) | ||
|
||
# force=NA management | ||
force_old <- difftime(Sys.time(), file.mtime(outfile), units="h") > 24 | ||
if(is.null(force)) stop("force cannot be NULL. Must be TRUE, FALSE, NA or a number.") | ||
force <- rep(force, length=length(outfile)) # recycle vector | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
brry
Author
Owner
|
||
force[is.na(force) & force_old] <- TRUE # force if old | ||
force[is.na(force)] <- FALSE # otherwise don't | ||
fT <- sapply(force, isTRUE) | ||
fF <- sapply(force, isFALSE) | ||
if(any(fT)) force[fT] <- 0 | ||
if(any(fF)) force[fF] <- Inf | ||
force[is.na(force)] <- 24 | ||
force <- difftime(Sys.time(), file.mtime(outfile), units="h") > force | ||
|
||
dontdownload <- file.exists(outfile) & !force | ||
if( any(dontdownload) & !quiet ) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Hi! For the following use of
dataDWD
this does not seem to work as expected.While debugging I found after line 154
force
iswhile
outfile
yieldsThis results in only half of my
_hist
files being updated and only half of my_akt
files being updated.