mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-04 12:13:27 +00:00
fix first time library creation
This commit is contained in:
parent
9ffaa87618
commit
077bf760ee
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
|
|
Loading…
Reference in a new issue