Skip to content

Commit

Permalink
moss/client: Initialise the required databases
Browse files Browse the repository at this point in the history
Without these DBs we can't honestly achieve an awful lot =)

Signed-off-by: Ikey Doherty <ikey@serpentos.com>
  • Loading branch information
ikeycode committed Oct 8, 2023
1 parent db7ffcf commit a6c5d6a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions moss/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::path::PathBuf;
use thiserror::Error;

use crate::{
db,
registry::plugin::{self, Plugin},
repository, Installation, Registry,
};
Expand All @@ -17,6 +18,13 @@ pub enum Error {
RootInvalid,
#[error("repository: {0}")]
Repository(#[from] repository::manager::Error),
#[error("meta: {0}")]
Meta(#[from] db::meta::Error),

#[error("layout: {0}")]
Layout(#[from] db::layout::Error),
#[error("state: {0}")]
State(#[from] db::state::Error),
}

/// A Client is a connection to the underlying package management systems
Expand All @@ -25,6 +33,10 @@ pub struct Client {
pub installation: Installation,
repositories: repository::Manager,
pub registry: Registry,

pub install_db: db::meta::Database,
pub state_db: db::state::Database,
pub layout_db: db::layout::Database,
}

impl Client {
Expand All @@ -38,13 +50,21 @@ impl Client {

let installation = Installation::open(root);
let repositories = repository::Manager::new(installation.clone()).await?;
let install_db =
db::meta::Database::new(installation.db_path("install"), installation.read_only())
.await?;
let state_db = db::state::Database::new(&installation).await?;
let layout_db = db::layout::Database::new(&installation).await?;

let registry = build_registry(&repositories);

Ok(Client {
installation,
repositories,
registry,
install_db,
state_db,
layout_db,
})
}

Expand Down

0 comments on commit a6c5d6a

Please sign in to comment.