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
List cded dir with sum of file sizes
  • Loading branch information
ateucher committed Jan 28, 2021
commit 23f3b9e7e6fb355c4611dfb5edbc8608fccbdeac
24 changes: 18 additions & 6 deletions R/cache-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ delete_cache <- function(files_to_delete = NULL) {

}

list_cached_files <- function() {
file.path(list.files(data_dir(), full.names = TRUE))
}

#' Show the files you have in your cache
#'
#' @rdname delete_cache
Expand All @@ -71,18 +67,34 @@ list_cached_files <- function() {
#'
#' @export
show_cached_files <- function() {
files <- list_cached_files()
files <- tidy_files(list_cached_files())
if (any(grepl("cded", files$file))) {
cded_files <- tidy_files(list_cded_files())
total_cded_size <- sum(cded_files$size_MB, na.rm = TRUE)
files$size_MB[grepl("cded", files$file)] <- total_cded_size
}
files
}

tidy_files <- function(files) {
tbl <- file.info(files)
tbl$file <- rownames(tbl)
rownames(tbl) <- NULL
tbl$size_MB <- tbl$size / 1e6
tbl$modified <- tbl$mtime
tbl$is_dir <- tbl$isdir
tbl <- tbl[, c("file", "size_MB", "is_dir", "modified")]
tbl <- tbl[, c("file", "is_dir", "size_MB", "modified")]
class(tbl) <- c("tbl_df", "tbl", "data.frame")
tbl
}

list_cached_files <- function() {
list.files(data_dir(), full.names = TRUE)
}

list_cded_files <- function() {
list.files(file.path(data_dir(), "cded"), full.names = TRUE, recursive = TRUE)
}

add_rds_suffix <- function(x) {
exts <- tools::file_ext(x)
Expand Down