diff --git a/core/startos/src/install/mod.rs b/core/startos/src/install/mod.rs index bb7d1a02e..707503615 100644 --- a/core/startos/src/install/mod.rs +++ b/core/startos/src/install/mod.rs @@ -198,12 +198,22 @@ pub async fn sideload(ctx: RpcContext) -> Result { use axum::extract::ws::Message; async move { if let Err(e) = async { - let id = id_recv.await.map_err(|_| { + let id = match id_recv.await.map_err(|_| { Error::new( eyre!("Could not get id to watch progress"), ErrorKind::Cancelled, ) - })?; + }).and_then(|a|a) { + Ok(a) => a, + Err(e) =>{ ws.send(Message::Text( + serde_json::to_string(&Err::<(), _>(RpcError::from(e.clone_output()))) + .with_kind(ErrorKind::Serialization)?, + )) + .await + .with_kind(ErrorKind::Network)?; + return Err(e); + } + }; tokio::select! { res = async { while let Some(_) = sub.recv().await { @@ -259,17 +269,25 @@ pub async fn sideload(ctx: RpcContext) -> Result { .await; tokio::spawn(async move { if let Err(e) = async { - let s9pk = S9pk::deserialize( + match S9pk::deserialize( &file, None, // TODO ) - .await?; - let _ = id_send.send(s9pk.as_manifest().id.clone()); - ctx.services - .install(ctx.clone(), s9pk, None::) - .await? - .await? - .await?; - file.delete().await + .await + { + Ok(s9pk) => { + let _ = id_send.send(Ok(s9pk.as_manifest().id.clone())); + ctx.services + .install(ctx.clone(), s9pk, None::) + .await? + .await? + .await?; + file.delete().await + } + Err(e) => { + let _ = id_send.send(Err(e.clone_output())); + return Err(e); + } + } } .await { diff --git a/core/startos/src/s9pk/v2/compat.rs b/core/startos/src/s9pk/v2/compat.rs index 835c86b87..ec5b586ea 100644 --- a/core/startos/src/s9pk/v2/compat.rs +++ b/core/startos/src/s9pk/v2/compat.rs @@ -209,7 +209,9 @@ impl S9pk> { .invoke(ErrorKind::Filesystem) .await?; archive.insert_path( - Path::new("assets").join(&asset_id), + Path::new("assets") + .join(&asset_id) + .with_extension("squashfs"), Entry::file(PackSource::File(sqfs_path)), )?; }