forked from kemitix/git-next
32 lines
952 B
Rust
32 lines
952 B
Rust
use actix::prelude::*;
|
|
use kxio::network::Network;
|
|
use tracing::error;
|
|
|
|
use crate::server::{
|
|
config::{ForgeType, RepoDetails},
|
|
forge,
|
|
};
|
|
|
|
use super::{LoadedConfig, RepoActor};
|
|
|
|
pub async fn load(details: RepoDetails, addr: Addr<RepoActor>, net: Network) {
|
|
let config = match details.config {
|
|
Some(config) => config,
|
|
None => {
|
|
let config = match details.forge.forge_type {
|
|
#[cfg(feature = "forgejo")]
|
|
ForgeType::ForgeJo => forge::forgejo::config::load(&details, &net).await,
|
|
#[cfg(test)]
|
|
ForgeType::MockForge => forge::mock::config::load(&details, &net).await,
|
|
};
|
|
match config {
|
|
Ok(config) => config,
|
|
Err(err) => {
|
|
error!(?err, "Failed to load config");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
addr.do_send(LoadedConfig(config));
|
|
}
|