Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index validation fix #179

Merged
merged 5 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pearl changelog


#### Fixed

- Correct blob size comparison in index validation
Boneyan marked this conversation as resolved.
Show resolved Hide resolved

#### 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