bcgov / bcmaps

An R package of map layers for British Columbia
http://bcgov.github.io/bcmaps/
Apache License 2.0
73 stars 17 forks source link

Show files #93

Closed ateucher closed 3 years ago

ateucher commented 3 years ago

Adds more information to show_cached_files() so a user can know how much space they are taking up. #92

boshek commented 3 years ago

Looks great. Did we want to go through the trouble of compute the size of subfolders? Right now it just the cded but in the output of show_cached_files the CDED directory has a size zero.

ateucher commented 3 years ago

I wondered about that too... or an argument (or other function) to show the cded cache?

boshek commented 3 years ago

Feels like it belong in the show files function somehow especially since it is likely to be by far the biggest thing taking up space. I guess you could have show_cded_cached_files and then have show_cached_files call that?

ateucher commented 3 years ago

I guess just expanding the cded folder would be the simplest... with a cded (logical) argument whether or not you want to show it?

boshek commented 3 years ago

I think that might end up being less useful as 95% of the files are cded files. I wonder if we could summarise it by the directors or files at this location: bcmaps:::data_dir()? So in this case cded is just the sum of file sizes of a recursive list of what is in cded.

ateucher commented 3 years ago

Yeah that's good

ateucher commented 3 years ago

Ok, I think this works now. Lists the cded dir (or any dir, but right now that should be the only one) with the sum of the files. I also modified delete_cache() so that the cded dir is also deleted (when specified or when files_to_delete = NULL).

library(bcmaps)
#> Loading required package: sf
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1

show_cached_files()
#> # A tibble: 2 x 4
#>   file                                        is_dir size_MB modified           
#>   <chr>                                       <lgl>    <dbl> <dttm>             
#> 1 /Users/ateucher/Library/Caches/org.R-proje… FALSE   0.0191 2021-01-28 10:21:30
#> 2 /Users/ateucher/Library/Caches/org.R-proje… TRUE    8.66   2021-01-28 10:21:31

Created on 2021-01-28 by the reprex package (v0.3.0)