config changes; cleanup wip

This commit is contained in:
Aiden McClelland
2021-08-19 13:12:02 -06:00
committed by Aiden McClelland
parent 6c7dc71ed4
commit 0aa75ee008
5 changed files with 149 additions and 58 deletions

View File

@@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::action::ActionImplementation;
use crate::config::{Config, ConfigSpec};
use crate::db::model::CurrentDependencyInfo;
use crate::net::interface::InterfaceId;
use crate::s9pk::manifest::PackageId;
use crate::status::health_check::{HealthCheckId, HealthCheckResult, HealthCheckResultVariant};
@@ -254,3 +255,26 @@ impl DependencyConfig {
.map_err(|e| Error::new(anyhow!("{}", e.1), crate::ErrorKind::AutoConfigure))
}
}
pub async fn update_current_dependents<Db: DbHandle>(
db: &mut Db,
dependent_id: &PackageId,
current_dependencies: &IndexMap<PackageId, CurrentDependencyInfo>,
) -> Result<(), Error> {
for (dependency, dep_info) in current_dependencies {
if let Some(dependency_model) = crate::db::DatabaseModel::new()
.package_data()
.idx_model(&dependency)
.and_then(|pkg| pkg.installed())
.check(db)
.await?
{
dependency_model
.current_dependents()
.idx_model(dependent_id)
.put(db, &dep_info)
.await?;
}
}
Ok(())
}