Read and upgrade a local checkpoint without rewriting it.
(root: &Path)
| 224 | |
| 225 | /// Read and upgrade a local checkpoint without rewriting it. |
| 226 | pub(crate) fn read_checkpoint(root: &Path) -> Result<Option<ShimCheckpoint>, CheckpointError> { |
| 227 | let path = checkpoint_path(root); |
| 228 | let bytes = match fs::read(&path) { |
| 229 | Ok(bytes) => bytes, |
| 230 | Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(None), |
| 231 | Err(source) => return Err(CheckpointError::Read { path, source }), |
| 232 | }; |
| 233 | decode_checkpoint_at(&bytes, path).map(Some) |
| 234 | } |
| 235 | |
| 236 | fn decode_checkpoint_at(bytes: &[u8], path: PathBuf) -> Result<ShimCheckpoint, CheckpointError> { |
| 237 | let probe: VersionProbe = |