mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
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:
@@ -198,12 +198,22 @@ pub async fn sideload(ctx: RpcContext) -> Result<SideloadResponse, Error> {
|
|||||||
use axum::extract::ws::Message;
|
use axum::extract::ws::Message;
|
||||||
async move {
|
async move {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let id = id_recv.await.map_err(|_| {
|
let id = match id_recv.await.map_err(|_| {
|
||||||
Error::new(
|
Error::new(
|
||||||
eyre!("Could not get id to watch progress"),
|
eyre!("Could not get id to watch progress"),
|
||||||
ErrorKind::Cancelled,
|
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! {
|
tokio::select! {
|
||||||
res = async {
|
res = async {
|
||||||
while let Some(_) = sub.recv().await {
|
while let Some(_) = sub.recv().await {
|
||||||
@@ -259,17 +269,25 @@ pub async fn sideload(ctx: RpcContext) -> Result<SideloadResponse, Error> {
|
|||||||
.await;
|
.await;
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let s9pk = S9pk::deserialize(
|
match S9pk::deserialize(
|
||||||
&file, None, // TODO
|
&file, None, // TODO
|
||||||
)
|
)
|
||||||
.await?;
|
.await
|
||||||
let _ = id_send.send(s9pk.as_manifest().id.clone());
|
{
|
||||||
ctx.services
|
Ok(s9pk) => {
|
||||||
.install(ctx.clone(), s9pk, None::<Never>)
|
let _ = id_send.send(Ok(s9pk.as_manifest().id.clone()));
|
||||||
.await?
|
ctx.services
|
||||||
.await?
|
.install(ctx.clone(), s9pk, None::<Never>)
|
||||||
.await?;
|
.await?
|
||||||
file.delete().await
|
.await?
|
||||||
|
.await?;
|
||||||
|
file.delete().await
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
let _ = id_send.send(Err(e.clone_output()));
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -209,7 +209,9 @@ impl S9pk<Section<MultiCursorFile>> {
|
|||||||
.invoke(ErrorKind::Filesystem)
|
.invoke(ErrorKind::Filesystem)
|
||||||
.await?;
|
.await?;
|
||||||
archive.insert_path(
|
archive.insert_path(
|
||||||
Path::new("assets").join(&asset_id),
|
Path::new("assets")
|
||||||
|
.join(&asset_id)
|
||||||
|
.with_extension("squashfs"),
|
||||||
Entry::file(PackSource::File(sqfs_path)),
|
Entry::file(PackSource::File(sqfs_path)),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user