Skip to content

Commit b568255

Browse files
committed
fix store_dir creation bug
1 parent 7b6e566 commit b568255

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

mithril-aggregator/src/command_args.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,13 @@ impl ServeCommand {
198198

199199
// start the monitoring thread
200200
let mut event_store = dependencies_builder.create_event_store().await?;
201+
let event_store_config = config.clone();
201202
let event_store_thread = tokio::spawn(async move {
202203
event_store
203204
.run(Some(
204-
config.data_stores_directory.join(SQLITE_MONITORING_FILE),
205+
event_store_config
206+
.get_sqlite_dir()
207+
.join(SQLITE_MONITORING_FILE),
205208
))
206209
.await
207210
.unwrap()

mithril-aggregator/src/configuration.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::{LocalSnapshotUploader, RemoteSnapshotUploader, SnapshotUploader};
1515

1616
// TODO: 'LIST_SNAPSHOTS_MAX_ITEMS' keep as const or in config, or add a parameter to `list_snapshots`?
1717
pub const LIST_SNAPSHOTS_MAX_ITEMS: usize = 20;
18-
const SQLITE_FILE: &str = "aggregator.sqlite3";
1918

2019
/// Different kinds of execution environments
2120
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
@@ -188,14 +187,14 @@ impl Configuration {
188187
}
189188

190189
/// Return the file of the SQLite stores. If the directory does not exist, it is created.
191-
pub fn get_sqlite_file(&self) -> PathBuf {
190+
pub fn get_sqlite_dir(&self) -> PathBuf {
192191
let store_dir = &self.data_stores_directory;
193192

194193
if !store_dir.exists() {
195194
std::fs::create_dir_all(store_dir).unwrap();
196195
}
197196

198-
self.data_stores_directory.join(SQLITE_FILE)
197+
self.data_stores_directory.clone()
199198
}
200199
}
201200

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ use crate::{
5151

5252
use super::{DependenciesBuilderError, Result};
5353

54+
const SQLITE_FILE: &str = "aggregator.sqlite3";
55+
5456
/// Dependencies container builder
5557
pub struct DependenciesBuilder {
5658
/// Configuration parameters
@@ -184,7 +186,7 @@ impl DependenciesBuilder {
184186
async fn build_sqlite_connection(&self) -> Result<Arc<Mutex<Connection>>> {
185187
let connection = match self.configuration.environment {
186188
ExecutionEnvironment::Production => {
187-
Connection::open(self.configuration.get_sqlite_file())
189+
Connection::open(self.configuration.get_sqlite_dir().join(SQLITE_FILE))
188190
}
189191
_ => Connection::open(":memory:"),
190192
};
@@ -414,7 +416,7 @@ impl DependenciesBuilder {
414416
match self.configuration.environment {
415417
ExecutionEnvironment::Production => {
416418
let adapter =
417-
SQLiteAdapter::new("certificate", self.get_sqlite_connection().await?)
419+
SQLiteAdapter::new("verification_key", self.get_sqlite_connection().await?)
418420
.map_err(|e| DependenciesBuilderError::Initialization {
419421
message: "Cannot create SQLite adapter for VerificationKeyStore."
420422
.to_string(),
@@ -977,6 +979,7 @@ impl DependenciesBuilder {
977979

978980
Ok(dependency_manager)
979981
}
982+
980983
/// Create dependencies for the [EventStore] task.
981984
pub async fn create_event_store(&mut self) -> Result<EventStore> {
982985
let event_store = EventStore::new(self.get_event_transmitter_receiver().await?);
@@ -998,7 +1001,7 @@ impl DependenciesBuilder {
9981001
error: Some(e.into()),
9991002
})?
10001003
.ok_or(DependenciesBuilderError::Initialization {
1001-
message: "cannot build aggrgator runner: impossible to retrieve current epoch"
1004+
message: "cannot build aggregator runner: impossible to retrieve current epoch"
10021005
.to_string(),
10031006
error: None,
10041007
})?;

0 commit comments

Comments
 (0)