| 1734 | } |
| 1735 | |
| 1736 | pub fn clear_cache(log: &Logger, path: &str) { |
| 1737 | let cache_path = Path::new(path).to_path_buf(); |
| 1738 | if cache_path.exists() { |
| 1739 | log.debug(format!("Clearing cache at: {}", cache_path.display())); |
| 1740 | fs::remove_dir_all(&cache_path).unwrap_or_else(|err| { |
| 1741 | log.warn(format!( |
| 1742 | "The cache {} cannot be cleared: {}", |
| 1743 | cache_path.display(), |
| 1744 | err |
| 1745 | )) |
| 1746 | }); |
| 1747 | } |
| 1748 | } |
| 1749 | |
| 1750 | /// Removes cached driver and browser binaries whose `last_used` timestamp (tracked in the |
| 1751 | /// `cached_assets` section of the metadata) is older than `ttl_days` days. |