| 1786 | } |
| 1787 | |
| 1788 | pub fn clear_cache(log: &Logger, path: &str) { |
| 1789 | let cache_path = Path::new(path).to_path_buf(); |
| 1790 | if cache_path.exists() { |
| 1791 | log.debug(format!("Clearing cache at: {}", cache_path.display())); |
| 1792 | fs::remove_dir_all(&cache_path).unwrap_or_else(|err| { |
| 1793 | log.warn(format!( |
| 1794 | "The cache {} cannot be cleared: {}", |
| 1795 | cache_path.display(), |
| 1796 | err |
| 1797 | )) |
| 1798 | }); |
| 1799 | } |
| 1800 | } |
| 1801 | |
| 1802 | /// Removes cached driver and browser binaries whose `last_used` timestamp (tracked in the |
| 1803 | /// `cached_assets` section of the metadata) is older than `ttl_days` days. |