Skip to content

Commit

Permalink
Revert "update leptos"
Browse files Browse the repository at this point in the history
This reverts commit af325a4.

This leads to a memory leak
  • Loading branch information
DolceTriade committed Mar 17, 2024
1 parent 0b05b98 commit 1b008ac
Show file tree
Hide file tree
Showing 7 changed files with 2,667 additions and 2,249 deletions.
2 changes: 2 additions & 0 deletions blade/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ cfg_if! {
tracing::info!("Starting blade server at: {}", addr.to_string());
let fut1 = HttpServer::new(move || {
let leptos_options = &conf.leptos_options;
let fn_state = actix_state.clone();
let rt_state = actix_state.clone();
App::new()
.route("/api/{tail:.*}", leptos_actix::handle_server_fns_with_context(move|| provide_context(fn_state.clone())))
// serve JS/WASM/CSS from `pkg`
.service(Files::new("/pkg", pkg.clone()))
// serve other assets from the `assets` directory
Expand Down
21 changes: 12 additions & 9 deletions blade/routes/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ use std::sync::Arc;
#[server]
pub async fn get_artifact(uri: String) -> Result<Vec<u8>, ServerFnError> {
let global: Arc<state::Global> = use_context::<Arc<state::Global>>().unwrap();
let parsed = url::Url::parse(&uri).map_err(|e| ServerFnError::new(format!("{e:#?}")))?;
let parsed =
url::Url::parse(&uri).map_err(|e| ServerFnError::ServerError(format!("{e:#?}")))?;
match parsed.scheme() {
"file" => {
if !global.allow_local {
return Err(ServerFnError::new("not implemented".to_string()));
return Err(ServerFnError::ServerError("not implemented".to_string()));
}
let path = parsed
.to_file_path()
.map_err(|e| ServerFnError::new(format!("{e:#?}")))?;
std::fs::read(path).map_err(|e| ServerFnError::new(format!("{e:#?}")))
.map_err(|e| ServerFnError::ServerError(format!("{e:#?}")))?;
return std::fs::read(path).map_err(|e| ServerFnError::ServerError(format!("{e:#?}")));
}
"bytestream" | "http" | "https" => {
return global
.bytestream_client
.download_file(&uri)
.await
.map_err(|e| ServerFnError::ServerError(format!("failed to get artifact: {e}")));
}
"bytestream" | "http" | "https" => global
.bytestream_client
.download_file(&uri)
.await
.map_err(|e| ServerFnError::new(format!("failed to get artifact: {e}"))),
_ => Err(ServerFnError::ServerError("not implemented".to_string())),
}
}
Expand Down
Loading

0 comments on commit 1b008ac

Please sign in to comment.