Skip to content

Commit

Permalink
Merge pull request #981 from dlachaumepalo/damien/979-fix-client-snap…
Browse files Browse the repository at this point in the history
…shot-command-with-download-dir-option

Fix snapshot download command error with `--download-dir` option in client
  • Loading branch information
jpraynaud committed Jun 15, 2023
2 parents 5a654fb + ad7f087 commit 2fc8a35
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mithril-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-client"
version = "0.3.3"
version = "0.3.4"
description = "A Mithril Client"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion mithril-client/src/dependencies/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ impl DependenciesBuilder {

async fn build_snapshot_service(&mut self) -> StdResult<Arc<dyn SnapshotService>> {
let snapshot_service = MithrilClientSnapshotService::new(
self.config.clone(),
self.get_snapshot_client().await?,
self.get_certificate_client().await?,
self.get_certificate_verifier().await?,
Expand Down
11 changes: 2 additions & 9 deletions mithril-client/src/services/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
};

use async_trait::async_trait;
use config::Config;
use flate2::read::GzDecoder;
use mithril_common::{
certificate_chain::CertificateVerifier,
Expand Down Expand Up @@ -81,9 +80,6 @@ pub trait SnapshotService: Sync + Send {

/// Service used by the Command to perform business oriented tasks.
pub struct MithrilClientSnapshotService {
/// Configuration settings
config: Arc<Config>,

/// Snapshot HTTP client
snapshot_client: Arc<SnapshotClient>,

Expand All @@ -100,14 +96,12 @@ pub struct MithrilClientSnapshotService {
impl MithrilClientSnapshotService {
/// Create a new instance of the service.
pub fn new(
config: Arc<Config>,
snapshot_client: Arc<SnapshotClient>,
certificate_client: Arc<CertificateClient>,
certificate_verifier: Arc<dyn CertificateVerifier>,
immutable_digester: Arc<dyn ImmutableDigester>,
) -> Self {
Self {
config,
snapshot_client,
certificate_client,
certificate_verifier,
Expand Down Expand Up @@ -198,7 +192,6 @@ impl SnapshotService for MithrilClientSnapshotService {
.download(snapshot, pathdir)
.await
.map_err(|e| format!("Could not download file in '{}': {e}", pathdir.display()))?;
let db_pathdir = Path::new(&self.config.get_string("download_dir")?).join("db");

self.unpack_snapshot(&filepath, &unpack_dir)
.await
Expand All @@ -211,12 +204,12 @@ impl SnapshotService for MithrilClientSnapshotService {
})?;
let unpacked_snapshot_digest = self
.immutable_digester
.compute_digest(&db_pathdir, &certificate.beacon)
.compute_digest(&unpack_dir, &certificate.beacon)
.await
.map_err(|e| {
format!(
"Could not compute digest in '{}': {e}",
db_pathdir.display()
unpack_dir.display()
)
})?;

Expand Down

0 comments on commit 2fc8a35

Please sign in to comment.