mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
fix config set dry
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -178,13 +179,68 @@ pub struct SetParams {
|
||||
// )]
|
||||
#[instrument(skip_all)]
|
||||
pub fn set<C: Context>() -> ParentHandler<C, SetParams, PackageId> {
|
||||
ParentHandler::new().root_handler(
|
||||
from_fn_async(set_impl)
|
||||
.with_metadata("sync_db", Value::Bool(true))
|
||||
.with_inherited(|set_params, id| (id, set_params))
|
||||
.no_display()
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
ParentHandler::new()
|
||||
.root_handler(
|
||||
from_fn_async(set_impl)
|
||||
.with_metadata("sync_db", Value::Bool(true))
|
||||
.with_inherited(|set_params, id| (id, set_params))
|
||||
.no_display()
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"dry",
|
||||
from_fn_async(set_dry)
|
||||
.with_inherited(|set_params, id| (id, set_params))
|
||||
.no_display()
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn set_dry(
|
||||
ctx: RpcContext,
|
||||
_: Empty,
|
||||
(
|
||||
id,
|
||||
SetParams {
|
||||
timeout,
|
||||
config: StdinDeserializable(config),
|
||||
},
|
||||
): (PackageId, SetParams),
|
||||
) -> Result<BTreeSet<PackageId>, Error> {
|
||||
let mut breakages = BTreeSet::new();
|
||||
|
||||
let procedure_id = Guid::new();
|
||||
|
||||
let db = ctx.db.peek().await;
|
||||
for dep in db
|
||||
.as_public()
|
||||
.as_package_data()
|
||||
.as_entries()?
|
||||
.into_iter()
|
||||
.filter_map(
|
||||
|(k, v)| match v.as_current_dependencies().contains_key(&id) {
|
||||
Ok(true) => Some(Ok(k)),
|
||||
Ok(false) => None,
|
||||
Err(e) => Some(Err(e)),
|
||||
},
|
||||
)
|
||||
{
|
||||
let dep_id = dep?;
|
||||
|
||||
let Some(dependent) = &*ctx.services.get(&dep_id).await else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if dependent
|
||||
.dependency_config(procedure_id.clone(), id.clone(), config.clone())
|
||||
.await?
|
||||
.is_some()
|
||||
{
|
||||
breakages.insert(dep_id);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(breakages)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
Reference in New Issue
Block a user