mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
don't wait for install to complete on sideload
This commit is contained in:
committed by
Aiden McClelland
parent
88869e9710
commit
f29c7ba4f2
@@ -443,7 +443,7 @@ async fn restore_package<'a>(
|
||||
Ok((
|
||||
progress.clone(),
|
||||
async move {
|
||||
download_install_s9pk(&ctx, &manifest, None, progress, file).await?;
|
||||
download_install_s9pk(&ctx, &manifest, None, progress, file, None).await?;
|
||||
|
||||
guard.unmount().await?;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use rpc_toolkit::yajrc::RpcError;
|
||||
use tokio::fs::{File, OpenOptions};
|
||||
use tokio::io::{AsyncRead, AsyncSeek, AsyncSeekExt};
|
||||
use tokio::process::Command;
|
||||
use tokio::sync::oneshot;
|
||||
use tokio_stream::wrappers::ReadDirStream;
|
||||
use tracing::instrument;
|
||||
|
||||
@@ -297,6 +298,7 @@ pub async fn install(
|
||||
Some(marketplace_url),
|
||||
InstallProgress::new(s9pk.content_length()),
|
||||
response_to_reader(s9pk),
|
||||
None,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -425,6 +427,9 @@ pub async fn sideload(
|
||||
pde.save(&mut tx).await?;
|
||||
tx.commit().await?;
|
||||
|
||||
let (send, recv) = oneshot::channel();
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = download_install_s9pk(
|
||||
&new_ctx,
|
||||
&manifest,
|
||||
@@ -440,6 +445,7 @@ pub async fn sideload(
|
||||
e,
|
||||
)
|
||||
})),
|
||||
Some(send),
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -466,6 +472,9 @@ pub async fn sideload(
|
||||
tracing::debug!("{:?}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
recv.await;
|
||||
|
||||
Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
@@ -707,6 +716,7 @@ pub async fn download_install_s9pk(
|
||||
marketplace_url: Option<Url>,
|
||||
progress: Arc<InstallProgress>,
|
||||
mut s9pk: impl AsyncRead + Unpin,
|
||||
download_complete: Option<oneshot::Sender<()>>,
|
||||
) -> Result<(), Error> {
|
||||
let pkg_id = &temp_manifest.id;
|
||||
let version = &temp_manifest.version;
|
||||
@@ -799,6 +809,9 @@ pub async fn download_install_s9pk(
|
||||
let mut progress_writer = InstallProgressTracker::new(&mut dst, progress.clone());
|
||||
tokio::io::copy(&mut s9pk, &mut progress_writer).await?;
|
||||
progress.download_complete();
|
||||
if let Some(complete) = download_complete {
|
||||
complete.send(()).unwrap_or_default();
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user