completion bool fixes

This commit is contained in:
Aiden McClelland
2021-08-24 11:01:42 -06:00
parent 28d2b18f09
commit 0aca612f2a
3 changed files with 16 additions and 3 deletions

View File

@@ -1,8 +1,10 @@
use std::borrow::Cow; use std::borrow::Cow;
use anyhow::anyhow; use anyhow::anyhow;
use bollard::Docker;
use patch_db::DbHandle; use patch_db::DbHandle;
use crate::context::RpcContext;
use crate::db::model::InstalledPackageDataEntry; use crate::db::model::InstalledPackageDataEntry;
use crate::dependencies::DependencyError; use crate::dependencies::DependencyError;
use crate::s9pk::manifest::{Manifest, PackageId}; use crate::s9pk::manifest::{Manifest, PackageId};
@@ -59,15 +61,21 @@ pub async fn update_dependents<'a, Db: DbHandle, I: IntoIterator<Item = &'a Pack
} }
pub async fn cleanup<Db: DbHandle>( pub async fn cleanup<Db: DbHandle>(
ctx: &RpcContext,
db: &mut Db, db: &mut Db,
info: Result<InstalledPackageDataEntry, &Manifest>, info: Result<InstalledPackageDataEntry, &Manifest>,
) -> Result<(), Error> { ) -> Result<(), Error> {
let man = match info { let man = match info {
Ok(pde) => { Ok(pde) => {
todo!(); // TODO
Cow::Owned(pde.manifest) Cow::Owned(pde.manifest)
} }
Err(man) => Cow::Borrowed(man), Err(man) => Cow::Borrowed(man),
}; };
ctx.managers
.remove(&(man.id.clone(), man.version.clone()))
.await;
// docker images start9/$APP_ID/*:$VERSION -q | xargs docker rmi
Ok(()) // TODO Ok(()) // TODO
} }

View File

@@ -185,6 +185,8 @@ pub async fn download_install_s9pk(
.await; .await;
let mut s9pk_reader = if let Some(cached) = cached { let mut s9pk_reader = if let Some(cached) = cached {
progress.download_complete();
progress_model.put(&mut ctx.db.handle(), &progress).await?;
cached cached
} else { } else {
File::delete(&pkg_cache).await?; File::delete(&pkg_cache).await?;
@@ -238,7 +240,7 @@ pub async fn download_install_s9pk(
if let Err(e) = res { if let Err(e) = res {
let mut handle = ctx.db.handle(); let mut handle = ctx.db.handle();
if let Err(e) = cleanup(&mut handle, Err(temp_manifest)).await { if let Err(e) = cleanup(&ctx, &mut handle, Err(temp_manifest)).await {
log::error!( log::error!(
"Failed to clean up {}@{}: {}: Adding to broken packages", "Failed to clean up {}@{}: {}: Adding to broken packages",
pkg_id, pkg_id,
@@ -561,7 +563,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
{ {
configured &= res.configured; configured &= res.configured;
} }
cleanup(&mut tx, Ok(prev)).await?; cleanup(&ctx, &mut tx, Ok(prev)).await?;
if let Some(res) = manifest if let Some(res) = manifest
.migrations .migrations
.from(&prev_manifest.version, pkg_id, version, &manifest.volumes) .from(&prev_manifest.version, pkg_id, version, &manifest.volumes)

View File

@@ -122,6 +122,9 @@ impl<RW> InstallProgressTracker<RW> {
} }
pub fn validated(&mut self) { pub fn validated(&mut self) {
self.validating = false; self.validating = false;
self.progress
.validation_complete
.store(true, Ordering::SeqCst);
} }
} }
impl<W: AsyncWrite> AsyncWrite for InstallProgressTracker<W> { impl<W: AsyncWrite> AsyncWrite for InstallProgressTracker<W> {