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

Commit

Permalink
style: apply linting
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalinDe committed Nov 6, 2023
1 parent 2fd4a9f commit 954b302
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ impl Client {
.state_dir(CfgPath::new_literal(cache_path));

let auth_path = cache_path.join(Self::AUTHORITY_FILENAME);
let auth_raw = fs::read_to_string(auth_path.clone()).context(format!("Failed to read {}", auth_path.to_string_lossy()))?;
let auth_raw = fs::read_to_string(auth_path.clone())
.context(format!("Failed to read {}", auth_path.to_string_lossy()))?;
let auth = serde_json::from_str(auth_raw.as_str())?;

cfg_builder.tor_network().set_authorities(vec![auth]);
Expand Down
18 changes: 14 additions & 4 deletions src/flatfiledirmgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,22 @@ impl<R: Runtime> FlatFileDirMgr<R> {
/// Check cache directory content.
pub fn check_directory(&self, cache_path: &Path) -> Result<()> {
let mut any_missing = false;
for filename in vec![Self::CONSENSUS_FILENAME, Self::MICRODESCRIPTORS_FILENAME, Self::CERTIFICATE_FILENAME, Self::CHURN_FILENAME, Self::AUTHORITY_FILENAME].iter() {
for filename in vec![
Self::CONSENSUS_FILENAME,
Self::MICRODESCRIPTORS_FILENAME,
Self::CERTIFICATE_FILENAME,
Self::CHURN_FILENAME,
Self::AUTHORITY_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"))
return Err(Error::CacheCorruption("required files missing in cache"));
}
Ok(())
}
Expand Down Expand Up @@ -218,7 +226,8 @@ impl<R: Runtime> FlatFileDirMgr<R> {
/// Load the certificate from a flat file.
fn load_certificate(&self, cache_path: &Path) -> Result<AuthCert> {
let path = cache_path.join(Self::CERTIFICATE_FILENAME);
let certificate = fs::read_to_string(path.clone()).map_err(|_| Error::UnrecognizedAuthorities)?;
let certificate =
fs::read_to_string(path.clone()).map_err(|_| Error::UnrecognizedAuthorities)?;
debug!("{} loaded", path.to_string_lossy());

let parsed = AuthCert::parse(certificate.as_str())
Expand All @@ -234,7 +243,8 @@ impl<R: Runtime> FlatFileDirMgr<R> {
/// Load the list of microdescriptors from a flat file.
fn load_microdesc(&self, cache_path: &Path) -> Result<Vec<Microdesc>> {
let path = cache_path.join(Self::MICRODESCRIPTORS_FILENAME);
let udesc_text = fs::read_to_string(path.clone()).map_err(|_| Error::UnrecognizedAuthorities)?;
let udesc_text =
fs::read_to_string(path.clone()).map_err(|_| Error::UnrecognizedAuthorities)?;
debug!("{} loaded", path.to_string_lossy());

let udesc = MicrodescReader::new(
Expand Down

0 comments on commit 954b302

Please sign in to comment.