Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show files #93

Merged
merged 9 commits into from
Jan 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modify delete_cache to allow deletion of cded dir
  • Loading branch information
ateucher committed Jan 28, 2021
commit d68e71875946ff13a13ee6521c6a3fab94f535d1
9 changes: 5 additions & 4 deletions R/cache-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@
delete_cache <- function(files_to_delete = NULL) {
files <- list_cached_files()

if(is.null(files_to_delete)) {
if (is.null(files_to_delete)) {
if (interactive()) {
ans <- ask(paste0("These are all the files you currently have stored locally: \n",
paste0(files, collapse = "\n"),
"\n \nAre you sure you want to delete all these files: \n"))
if (!ans) stop("Phewf! Glad you re-considered.", call. = FALSE)
}
} else {
files <- file.path(data_dir(), add_rds_suffix(files_to_delete))
files <- file.path(data_dir(), files_to_delete)
files <- add_rds_suffix(files)
}

unlink(files)
unlink(files, recursive = TRUE)

## return FALSE if any file isn't deleted
invisible(all(!file.exists(files)))
Expand Down Expand Up @@ -98,6 +99,6 @@ list_cded_files <- function() {

add_rds_suffix <- function(x) {
exts <- tools::file_ext(x)
ifelse(exts == "" , paste0(x, ".rds"), x)
ifelse(exts == "" & !dir.exists(x), paste0(x, ".rds"), x)
}