fix: Create org if it doesn't exist
parent
6549bebf2c
commit
a7d33b803c
|
@ -116,10 +116,14 @@ impl Database {
|
|||
org_id: u32,
|
||||
bucket_name: &str,
|
||||
) -> Result<Option<u32>, StorageError> {
|
||||
if !self.organizations.read().await.contains_key(&org_id) {
|
||||
let mut orgs = self.organizations.write().await;
|
||||
orgs.insert(org_id, RwLock::new(Organization::default()));
|
||||
}
|
||||
|
||||
let orgs = self.organizations.read().await;
|
||||
let org = orgs.get(&org_id).ok_or_else(|| StorageError {
|
||||
description: format!("org {} not found", org_id),
|
||||
})?;
|
||||
|
||||
let org = orgs.get(&org_id).expect("Should have found or just inserted org");
|
||||
|
||||
let id = match org.read().await.bucket_name_to_id.get(bucket_name) {
|
||||
Some(id) => Some(*id),
|
||||
|
|
Loading…
Reference in New Issue