| 734 | } |
| 735 | |
| 736 | fn read_stats_file(path: &Path) -> Option<ModuleCacheStatistics> { |
| 737 | fs::read_to_string(path) |
| 738 | .map_err(|err| { |
| 739 | trace!( |
| 740 | "Failed to read stats file, path: {}, err: {}", |
| 741 | path.display(), |
| 742 | err |
| 743 | ) |
| 744 | }) |
| 745 | .and_then(|contents| { |
| 746 | toml::from_str::<ModuleCacheStatistics>(&contents).map_err(|err| { |
| 747 | trace!( |
| 748 | "Failed to parse stats file, path: {}, err: {}", |
| 749 | path.display(), |
| 750 | err, |
| 751 | ) |
| 752 | }) |
| 753 | }) |
| 754 | .ok() |
| 755 | } |
| 756 | |
| 757 | fn write_stats_file(path: &Path, stats: &ModuleCacheStatistics) -> bool { |
| 758 | toml::to_string_pretty(&stats) |