fix first time library creation

This commit is contained in:
Jamie Pine 2022-03-31 22:37:18 -07:00
parent 9ffaa87618
commit 077bf760ee
2 changed files with 3 additions and 9 deletions

View file

@ -9,22 +9,18 @@ pub enum DatabaseError {
MissingConnection,
#[error("Unable find current_library in the client config")]
MalformedConfig,
#[error("Unable to initialise the Prisma client")]
#[error("Unable to initialize the Prisma client")]
ClientError(#[from] prisma::NewClientError),
}
pub async fn create_connection() -> Result<PrismaClient, DatabaseError> {
let config = state::client::get();
let current_library = config
.libraries
.iter()
.find(|l| l.library_uuid == config.current_library_uuid)
.ok_or(DatabaseError::MalformedConfig)?;
let current_library = config.get_current_library();
let path = current_library.library_path.clone();
// TODO: Error handling when brendan adds it to prisma-client-rust
let client = prisma::new_client_with_url(&format!("file:{}", &path)).await?;
Ok(client)
}

View file

@ -76,8 +76,6 @@ impl ClientState {
let file = fs::File::open(config_path)?;
let reader = BufReader::new(file);
let data = serde_json::from_reader(reader)?;
println!("data:::: {:?}", data);
// assign to self
*self = data;
Ok(())