Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
fix: apply code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalinDe committed Nov 8, 2023
1 parent 2c46798 commit 5b0d808
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Client {
}
if !cache_path.join(AUTHORITY_FILENAME).exists() {
debug!("required file missing: {}", AUTHORITY_FILENAME);
return Err(Error::CacheCorruption("required files missing in cache").into());
return Err(Error::CacheCorruption("required file(s) missing in cache").into());
}
Ok(())
}
Expand Down
16 changes: 6 additions & 10 deletions src/flatfiledirmgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,18 @@ impl<R: Runtime> FlatFileDirMgr<R> {

/// Check cache directory content.
fn check_directory(cache_path: &Path) -> Result<()> {
let mut any_missing = false;
for filename in [
let missing_files: Vec<&&str> = [
CONSENSUS_FILENAME,
MICRODESCRIPTORS_FILENAME,
CERTIFICATE_FILENAME,
CHURN_FILENAME,
]
.iter()
{
if !cache_path.join(filename).exists() {
any_missing = true;
debug!("required file missing: {filename}");
}
}
if any_missing {
return Err(Error::CacheCorruption("required files missing in cache"));
.filter(|filename| !cache_path.join(filename).exists())
.collect();
if !missing_files.is_empty() {
debug!("required file(s) missing: {missing_files:?}");
return Err(Error::CacheCorruption("required file(s) missing in cache"));
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async fn test_required_files_missing() {
let root_cause = error.root_cause();
assert_eq!(
format!("{}", root_cause),
"Corrupt cache: required files missing in cache"
"Corrupt cache: required file(s) missing in cache"
);
}
}
Expand Down

0 comments on commit 5b0d808

Please sign in to comment.