fix: Undoing the breaking introduced by trying to stopp (#2023)

* fix: Undoing the breaking introduced by trying to stopp

* add check for exists
This commit is contained in:
J M
2022-12-03 17:50:25 -07:00
committed by GitHub
parent d8c39c42a1
commit 785ed480bb

View File

@@ -713,7 +713,18 @@ pub async fn download_install_s9pk(
let mut previous_state: Option<MainStatus> = None;
if let Err(e) = async {
previous_state = Some(crate::control::stop_impl(ctx.clone(), pkg_id.clone()).await?);
if crate::db::DatabaseModel::new()
.package_data()
.idx_model(&pkg_id)
.and_then(|x| x.installed())
.exists(&mut ctx.db.handle())
.await
.unwrap_or(false)
{
previous_state = crate::control::stop_impl(ctx.clone(), pkg_id.clone())
.await
.ok();
}
let mut db_handle = ctx.db.handle();
let mut tx = db_handle.begin().await?;
let receipts = DownloadInstallReceipts::new(&mut tx, &pkg_id).await?;