mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
@@ -198,7 +198,7 @@ pub async fn recover_full_embassy(
|
||||
async move {
|
||||
let rpc_ctx = RpcContext::init(ctx.config_path.as_ref(), disk_guid).await?;
|
||||
let mut db = rpc_ctx.db.handle();
|
||||
|
||||
|
||||
let ids = backup_guard
|
||||
.metadata
|
||||
.package_backups
|
||||
|
||||
@@ -232,6 +232,7 @@ pub async fn set_dry(
|
||||
.configured()
|
||||
.put(&mut tx, &true)
|
||||
.await?;
|
||||
tx.abort().await?;
|
||||
Ok(BreakageRes(breakages))
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,8 @@ pub async fn stop_dry(
|
||||
let mut breakages = BTreeMap::new();
|
||||
stop_common(&mut tx, &id, &mut breakages).await?;
|
||||
|
||||
tx.abort().await?;
|
||||
|
||||
Ok(BreakageRes(breakages))
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ use crate::{Error, ErrorKind, ResultExt};
|
||||
|
||||
pub mod cleanup;
|
||||
pub mod progress;
|
||||
pub mod update;
|
||||
|
||||
pub const PKG_ARCHIVE_DIR: &'static str = "package-data/archive";
|
||||
pub const PKG_PUBLIC_DIR: &'static str = "package-data/public";
|
||||
@@ -393,6 +394,8 @@ pub async fn uninstall_dry(
|
||||
break_all_dependents_transitive(&mut tx, &id, DependencyError::NotInstalled, &mut breakages)
|
||||
.await?;
|
||||
|
||||
tx.abort().await?;
|
||||
|
||||
Ok(BreakageRes(breakages))
|
||||
}
|
||||
|
||||
@@ -946,7 +949,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
{
|
||||
configured &= res.configured;
|
||||
}
|
||||
if configured {
|
||||
if configured && manifest.config.is_some() {
|
||||
crate::config::configure(
|
||||
ctx,
|
||||
&mut tx,
|
||||
@@ -1041,7 +1044,7 @@ async fn handle_recovered_package(
|
||||
} else {
|
||||
false
|
||||
};
|
||||
if configured {
|
||||
if configured && manifest.config.is_some() {
|
||||
crate::config::configure(
|
||||
ctx,
|
||||
tx,
|
||||
|
||||
71
appmgr/src/install/update.rs
Normal file
71
appmgr/src/install/update.rs
Normal file
@@ -0,0 +1,71 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use patch_db::{DbHandle, LockType};
|
||||
use rpc_toolkit::command;
|
||||
|
||||
use crate::context::RpcContext;
|
||||
use crate::dependencies::{break_transitive, BreakageRes, DependencyError};
|
||||
use crate::s9pk::manifest::PackageId;
|
||||
use crate::util::{display_serializable, Version};
|
||||
use crate::Error;
|
||||
|
||||
#[command(subcommands(dry))]
|
||||
pub async fn update() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command(display(display_serializable))]
|
||||
pub async fn dry(
|
||||
#[context] ctx: RpcContext,
|
||||
#[arg] id: PackageId,
|
||||
#[arg] version: Version,
|
||||
) -> Result<BreakageRes, Error> {
|
||||
let mut db = ctx.db.handle();
|
||||
let mut tx = db.begin().await?;
|
||||
let mut breakages = BTreeMap::new();
|
||||
crate::db::DatabaseModel::new()
|
||||
.package_data()
|
||||
.lock(&mut tx, LockType::DeepRead)
|
||||
.await;
|
||||
for dependent in crate::db::DatabaseModel::new()
|
||||
.package_data()
|
||||
.idx_model(&id)
|
||||
.and_then(|m| m.installed())
|
||||
.expect(&mut tx)
|
||||
.await?
|
||||
.current_dependents()
|
||||
.keys(&mut tx, true)
|
||||
.await?
|
||||
{
|
||||
let version_req = crate::db::DatabaseModel::new()
|
||||
.package_data()
|
||||
.idx_model(&dependent)
|
||||
.and_then(|m| m.installed())
|
||||
.expect(&mut tx)
|
||||
.await?
|
||||
.manifest()
|
||||
.dependencies()
|
||||
.idx_model(&id)
|
||||
.expect(&mut tx)
|
||||
.await?
|
||||
.get(&mut tx, true)
|
||||
.await?
|
||||
.into_owned()
|
||||
.version;
|
||||
if !version.satisfies(&version_req) {
|
||||
break_transitive(
|
||||
&mut tx,
|
||||
&dependent,
|
||||
&id,
|
||||
DependencyError::IncorrectVersion {
|
||||
expected: version_req,
|
||||
received: version.clone(),
|
||||
},
|
||||
&mut breakages,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
tx.abort().await?;
|
||||
Ok(BreakageRes(breakages))
|
||||
}
|
||||
@@ -87,6 +87,7 @@ pub fn server() -> Result<(), RpcError> {
|
||||
install::sideload,
|
||||
install::uninstall,
|
||||
install::list,
|
||||
install::update::update,
|
||||
config::config,
|
||||
control::start,
|
||||
control::stop,
|
||||
|
||||
Reference in New Issue
Block a user