fix compat assets (#2645)

* fix compat assets

* return error on s9pk parse fail in sideload

* return parse error over websocket
This commit is contained in:
Aiden McClelland
2024-06-17 10:37:57 -06:00
committed by GitHub
parent bb514d6216
commit e92d4ff147
2 changed files with 32 additions and 12 deletions

View File

@@ -198,12 +198,22 @@ pub async fn sideload(ctx: RpcContext) -> Result<SideloadResponse, Error> {
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<SideloadResponse, Error> {
.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::<Never>)
.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::<Never>)
.await?
.await?
.await?;
file.delete().await
}
Err(e) => {
let _ = id_send.send(Err(e.clone_output()));
return Err(e);
}
}
}
.await
{

View File

@@ -209,7 +209,9 @@ impl S9pk<Section<MultiCursorFile>> {
.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)),
)?;
}