| 1752 | } |
| 1753 | |
| 1754 | pub fn clear_cache(log: &Logger, path: &str) { |
| 1755 | let cache_path = Path::new(path).to_path_buf(); |
| 1756 | if cache_path.exists() { |
| 1757 | log.debug(format!("Clearing cache at: {}", cache_path.display())); |
| 1758 | fs::remove_dir_all(&cache_path).unwrap_or_else(|err| { |
| 1759 | log.warn(format!( |
| 1760 | "The cache {} cannot be cleared: {}", |
| 1761 | cache_path.display(), |
| 1762 | err |
| 1763 | )) |
| 1764 | }); |
| 1765 | } |
| 1766 | } |
| 1767 | |
| 1768 | /// Removes cached driver and browser binaries whose `last_used` timestamp (tracked in the |
| 1769 | /// `cached_assets` section of the metadata) is older than `ttl_days` days. |