Skip to content

Commit

Permalink
Index validation fix (#179)
Browse files Browse the repository at this point in the history
* correct blob path

* update changelog

* don't return error on non-existent blob

* Add number of pull request to CHANGELOG.md
  • Loading branch information
Boneyan authored Sep 5, 2022
1 parent 506966b commit c6956c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Pearl changelog
#### Changed
- Update rust edition (#175)


#### Fixed
- Correct blob size comparison in index validation (#179)
- Returning error when validating blob with corrupted records (#180)

#### Updated
Expand Down
13 changes: 12 additions & 1 deletion src/tools/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ where

static_assertions::const_assert_eq!(HEADER_VERSION, 5);
let header = read_index_header(path)?;
let blob_size = path.metadata()?.len();
let blob_path = path.with_extension("blob");
let blob_size =
if blob_path.exists() {
blob_path.metadata()?.len()
} else {
if let Some(path) = path.to_str() {
warn!("blob file doesn't exist for {}", path);
} else {
warn!("blob file doesn't exist for index");
}
header.blob_size()
};
let headers = if header.version() < HEADER_VERSION {
return Err(Error::index_header_validation_error(format!(
"Index version is outdated. Passed version: {}, latest version: {}",
Expand Down

0 comments on commit c6956c6

Please sign in to comment.