The local `load_change_data` — the raw on-disk change bytes (the exact bytes that produced the content hash), with the load+serialize fallback.
(repo: &Repository, hash: &Hash)
| 375 | /// The local `load_change_data` — the raw on-disk change bytes (the exact |
| 376 | /// bytes that produced the content hash), with the load+serialize fallback. |
| 377 | fn load_change_data(repo: &Repository, hash: &Hash) -> Result<Bytes, Status> { |
| 378 | let change_path = repo.change_store().change_path(hash); |
| 379 | if change_path.exists() { |
| 380 | let data = std::fs::read(&change_path).map_err(|error| { |
| 381 | domain_status( |
| 382 | ErrorCode::Repository, |
| 383 | format!("Failed to read change file {:?}: {error}", change_path), |
| 384 | ) |
| 385 | })?; |
| 386 | return Ok(Bytes::from(data)); |
| 387 | } |
| 388 | let change = repo.load_change(hash).map_err(|_| { |
| 389 | domain_status( |
| 390 | ErrorCode::Changes, |
| 391 | format!("change not found: {}", hash.to_base32()), |
| 392 | ) |
| 393 | })?; |
| 394 | let mut buffer = Vec::new(); |
| 395 | change.serialize(&mut buffer).map_err(|error| { |
| 396 | domain_status(ErrorCode::Repository, format!("serialize change: {error}")) |
| 397 | })?; |
| 398 | Ok(Bytes::from(buffer)) |
| 399 | } |
| 400 | |
| 401 | fn load_change_message(repo: &Repository, hash: &Hash) -> Option<String> { |
| 402 | repo.load_change(hash) |
no test coverage detected