mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
fix: Dependency vs dependents (#1462)
* fix: Dependency vs dependents * chore: Remove the debugging
This commit is contained in:
@@ -9,7 +9,8 @@ use super::{PKG_ARCHIVE_DIR, PKG_DOCKER_DIR};
|
||||
use crate::config::{not_found, ConfigReceipts};
|
||||
use crate::context::RpcContext;
|
||||
use crate::db::model::{
|
||||
AllPackageData, CurrentDependencyInfo, InstalledPackageDataEntry, PackageDataEntry,
|
||||
AllPackageData, CurrentDependencies, CurrentDependencyInfo, CurrentDependents,
|
||||
InstalledPackageDataEntry, PackageDataEntry,
|
||||
};
|
||||
use crate::dependencies::{
|
||||
reconfigure_dependents_with_live_pointers, DependencyErrors, TryHealReceipts,
|
||||
@@ -60,18 +61,14 @@ impl UpdateDependencyReceipts {
|
||||
}
|
||||
|
||||
#[instrument(skip(ctx, db, deps, receipts))]
|
||||
pub async fn update_dependency_errors_of_dependents<
|
||||
'a,
|
||||
Db: DbHandle,
|
||||
I: IntoIterator<Item = &'a PackageId>,
|
||||
>(
|
||||
pub async fn update_dependency_errors_of_dependents<'a, Db: DbHandle>(
|
||||
ctx: &RpcContext,
|
||||
db: &mut Db,
|
||||
id: &PackageId,
|
||||
deps: I,
|
||||
deps: &CurrentDependents,
|
||||
receipts: &UpdateDependencyReceipts,
|
||||
) -> Result<(), Error> {
|
||||
for dep in deps {
|
||||
for dep in deps.0.keys() {
|
||||
if let Some(man) = receipts.manifest.get(db, dep).await? {
|
||||
if let Err(e) = if let Some(info) = man.dependencies.0.get(id) {
|
||||
info.satisfied(ctx, db, id, None, dep, &receipts.try_heal)
|
||||
@@ -269,19 +266,15 @@ pub async fn cleanup_failed<Db: DbHandle>(
|
||||
}
|
||||
|
||||
#[instrument(skip(db, current_dependencies, current_dependent_receipt))]
|
||||
pub async fn remove_from_current_dependents_lists<
|
||||
'a,
|
||||
Db: DbHandle,
|
||||
I: IntoIterator<Item = &'a PackageId>,
|
||||
>(
|
||||
pub async fn remove_from_current_dependents_lists<'a, Db: DbHandle>(
|
||||
db: &mut Db,
|
||||
id: &'a PackageId,
|
||||
current_dependencies: I,
|
||||
current_dependent_receipt: &LockReceipt<BTreeMap<PackageId, CurrentDependencyInfo>, String>,
|
||||
current_dependencies: &'a CurrentDependencies,
|
||||
current_dependent_receipt: &LockReceipt<CurrentDependents, String>,
|
||||
) -> Result<(), Error> {
|
||||
for dep in current_dependencies.into_iter().chain(std::iter::once(id)) {
|
||||
for dep in current_dependencies.0.keys().chain(std::iter::once(id)) {
|
||||
if let Some(mut current_dependents) = current_dependent_receipt.get(db, dep).await? {
|
||||
if current_dependents.remove(id).is_some() {
|
||||
if current_dependents.0.remove(id).is_some() {
|
||||
current_dependent_receipt
|
||||
.set(db, current_dependents, dep)
|
||||
.await?;
|
||||
@@ -294,7 +287,7 @@ pub struct UninstallReceipts {
|
||||
config: ConfigReceipts,
|
||||
removing: LockReceipt<InstalledPackageDataEntry, ()>,
|
||||
packages: LockReceipt<AllPackageData, ()>,
|
||||
current_dependents: LockReceipt<BTreeMap<PackageId, CurrentDependencyInfo>, String>,
|
||||
current_dependents: LockReceipt<CurrentDependents, String>,
|
||||
update_depenency_receipts: UpdateDependencyReceipts,
|
||||
}
|
||||
impl UninstallReceipts {
|
||||
@@ -367,7 +360,7 @@ where
|
||||
remove_from_current_dependents_lists(
|
||||
&mut tx,
|
||||
&entry.manifest.id,
|
||||
entry.current_dependencies.keys(),
|
||||
&entry.current_dependencies,
|
||||
&receipts.current_dependents,
|
||||
)
|
||||
.await?;
|
||||
@@ -375,7 +368,7 @@ where
|
||||
ctx,
|
||||
&mut tx,
|
||||
&entry.manifest.id,
|
||||
entry.current_dependents.keys(),
|
||||
&entry.current_dependents,
|
||||
&receipts.update_depenency_receipts,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -29,8 +29,8 @@ use crate::config::ConfigReceipts;
|
||||
use crate::context::{CliContext, RpcContext};
|
||||
use crate::core::rpc_continuations::{RequestGuid, RpcContinuation};
|
||||
use crate::db::model::{
|
||||
CurrentDependencyInfo, InstalledPackageDataEntry, PackageDataEntry, RecoveredPackageInfo,
|
||||
StaticDependencyInfo, StaticFiles,
|
||||
CurrentDependencies, CurrentDependencyInfo, CurrentDependents, InstalledPackageDataEntry,
|
||||
PackageDataEntry, RecoveredPackageInfo, StaticDependencyInfo, StaticFiles,
|
||||
};
|
||||
use crate::db::util::WithRevision;
|
||||
use crate::dependencies::{
|
||||
@@ -1168,18 +1168,20 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
tracing::info!("Install {}@{}: Created manager", pkg_id, version);
|
||||
|
||||
let static_files = StaticFiles::local(pkg_id, version, manifest.assets.icon_type());
|
||||
let current_dependencies: BTreeMap<_, _> = manifest
|
||||
.dependencies
|
||||
.0
|
||||
.iter()
|
||||
.filter_map(|(id, info)| {
|
||||
if info.requirement.required() {
|
||||
Some((id.clone(), CurrentDependencyInfo::default()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let current_dependencies: CurrentDependencies = CurrentDependencies(
|
||||
manifest
|
||||
.dependencies
|
||||
.0
|
||||
.iter()
|
||||
.filter_map(|(id, info)| {
|
||||
if info.requirement.required() {
|
||||
Some((id.clone(), CurrentDependencyInfo::default()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
let current_dependents = {
|
||||
let mut deps = BTreeMap::new();
|
||||
for package in crate::db::DatabaseModel::new()
|
||||
@@ -1225,7 +1227,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
deps.insert(package, dep);
|
||||
}
|
||||
}
|
||||
deps
|
||||
CurrentDependents(deps)
|
||||
};
|
||||
let mut pde = model
|
||||
.clone()
|
||||
@@ -1360,7 +1362,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
remove_from_current_dependents_lists(
|
||||
&mut tx,
|
||||
pkg_id,
|
||||
prev.current_dependencies.keys(),
|
||||
&prev.current_dependencies,
|
||||
&receipts.config.current_dependents,
|
||||
)
|
||||
.await?; // remove previous
|
||||
@@ -1375,10 +1377,11 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
ctx,
|
||||
&mut tx,
|
||||
pkg_id,
|
||||
current_dependents
|
||||
.keys()
|
||||
.chain(prev.current_dependents.keys())
|
||||
.collect::<BTreeSet<_>>(),
|
||||
&CurrentDependents({
|
||||
let mut current_dependents = current_dependents.0.clone();
|
||||
current_dependents.append(&mut prev.current_dependents.0.clone());
|
||||
current_dependents
|
||||
}),
|
||||
&receipts.config.update_dependency_receipts,
|
||||
)
|
||||
.await?;
|
||||
@@ -1409,7 +1412,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
ctx,
|
||||
&mut tx,
|
||||
pkg_id,
|
||||
current_dependents.keys(),
|
||||
¤t_dependents,
|
||||
&receipts.config.update_dependency_receipts,
|
||||
)
|
||||
.await?;
|
||||
@@ -1441,7 +1444,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
ctx,
|
||||
&mut tx,
|
||||
pkg_id,
|
||||
current_dependents.keys(),
|
||||
¤t_dependents,
|
||||
&receipts.config.update_dependency_receipts,
|
||||
)
|
||||
.await?;
|
||||
@@ -1457,7 +1460,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
ctx,
|
||||
&mut tx,
|
||||
pkg_id,
|
||||
current_dependents.keys(),
|
||||
¤t_dependents,
|
||||
&receipts.config.update_dependency_receipts,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user