USAID-OHA-SI / glamr

SI Utilities
https://usaid-oha-si.github.io/glamr/
Other
2 stars 3 forks source link

return_lastest() - ctime vs mtime #82

Closed baboyma closed 1 year ago

baboyma commented 1 year ago

This function use ctime to pick the latest file matching the search. ctime is altered for backed up files leading to ctime > mtime. Should we switch to max(mtime) instead?

Sample code to reproduce this:

list.files(path = glamr::si_path("path_vector"), 
           pattern = "VcPepfarPolygons.shp$", 
           full.names = TRUE, 
           recursive = T) %>% 
  file.info() %>% 
  tibble::rownames_to_column(var = "filepath") %>% 
  dplyr::filter(ctime == max(ctime)) %>% 
  dplyr::pull(filepath)

list.files(path = glamr::si_path("path_vector"), 
           pattern = "VcPepfarPolygons.shp$", 
           full.names = TRUE, 
           recursive = T) %>% 
  file.info() %>% 
  tibble::rownames_to_column(var = "filepath") %>% 
  dplyr::filter(ctime == max(mtime)) %>% 
  dplyr::pull(filepath)
achafetz commented 1 year ago

In updating, needed to update both sides of the equation

https://github.com/USAID-OHA-SI/glamr/blob/32b2385257a5d848c75d5da67f0868e0275dc439/R/return_latest.R#L35

Should be dplyr::filter(mtime == max(mtime)) %>%