Nothing
#' @rdname rotate
#' @export
rotate_date <- function(
file,
age = 1,
size = 1,
max_backups = Inf,
compression = FALSE,
format = "%Y-%m-%d",
dir = dirname(file),
overwrite = FALSE,
create_file = TRUE,
now = Sys.Date(),
dry_run = FALSE,
verbose = dry_run
){
rotate_date_internal(
file = file,
age = age,
format = format,
size = size,
max_backups = max_backups,
compression = compression,
overwrite = overwrite,
dir = dir,
now = now,
dry_run = dry_run,
verbose = verbose,
create_file = create_file,
do_rotate = TRUE
)
}
#' @rdname rotate
#' @export
backup_date <- function(
file,
age = 1,
size = 1,
max_backups = Inf,
compression = FALSE,
format = "%Y-%m-%d",
dir = dirname(file),
overwrite = FALSE,
now = Sys.Date(),
dry_run = FALSE,
verbose = dry_run
){
rotate_date_internal(
file = file,
age = age,
format = format,
size = size,
max_backups = max_backups,
compression = compression,
overwrite = overwrite,
dir = dir,
now = now,
dry_run = dry_run,
verbose = verbose,
do_rotate = FALSE,
create_file = FALSE
)
}
rotate_date_internal <- function(
file,
age,
format,
size,
max_backups,
compression,
overwrite,
create_file,
dir,
now,
do_rotate,
dry_run,
verbose
){
stopifnot(
is_scalar_bool(do_rotate),
is_scalar_bool(dry_run),
is_scalar_bool(verbose),
is_scalar_bool(create_file)
)
assert_pure_BackupQueue(file, dir = dir, warn_only = TRUE)
if (dry_run){
DRY_RUN$activate()
on.exit(DRY_RUN$deactivate())
}
bq <- BackupQueueDate$new(
file,
fmt = format,
dir = dir,
compression = compression
)
# backup
if (bq$should_rotate(size = size, age = age, now = now, verbose = verbose)){
bq$push(
now = now,
overwrite = overwrite
)
} else {
do_rotate <- FALSE
}
# prune
bq$prune(max_backups)
# rotate
if (do_rotate){
file_remove(file)
if (create_file){
file_create(file)
}
}
invisible(file)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.