fixed panic: a field that should be there wasn't.

This commit is contained in:
Sebastian Moser
2023-01-08 04:18:55 +01:00
parent 40d10ae826
commit 0a82f3ee27
3 changed files with 6 additions and 9 deletions

View File

@@ -276,14 +276,11 @@ async fn render_item(uri: Uri) -> impl IntoResponse {
//#[axum_macros::debug_handler]
async fn get_render_main(extract::Path(id): extract::Path<String>, State(mutexes): State<Mutexes>) -> http::Response<String> {
let renders = &*mutexes.renders.lock().await;
println!("Render {:?}", renders);
let render = renders.iter().filter(|&render| render.id == id).nth(0)
.unwrap_or(renders.iter().filter(|&render| render.id == "first").nth(0).expect("there is no first render"));
println!("Render: {:?}", render);
let file_name = mutexes.mize_folder.clone() + "/modules-renders/" + &render.folder + "/" + &render.main;
println!("file_name: {}", file_name);
Response::builder()
.header("content-type", "application/javascript")

View File

@@ -32,8 +32,8 @@ impl Itemstore {
"next_free_id".as_bytes().to_vec(),
"_commit".as_bytes().to_vec(),
"_type".as_bytes().to_vec(),
"renders".as_bytes().to_vec(),
"modules".as_bytes().to_vec(),
//"renders".as_bytes().to_vec(),
//"modules".as_bytes().to_vec(),
];
tr.set("0".to_string().into_bytes(), encode(keys)).await?;
@@ -44,8 +44,8 @@ impl Itemstore {
tr.set("0:next_free_id".to_string().into_bytes(), one.to_be_bytes()).await?;
tr.set("0:_commit".to_string().into_bytes(), zero.to_be_bytes()).await?;
tr.set("0:_type".to_string().into_bytes(), "mize-main".as_bytes().to_vec()).await?;
tr.set("0:renders".to_string().into_bytes(), Vec::new());
tr.set("0:modules".to_string().into_bytes(), Vec::new());
//tr.set("0:renders".to_string().into_bytes(), Vec::new());
//tr.set("0:modules".to_string().into_bytes(), Vec::new());
tr.commit().await?;
},
@@ -167,7 +167,7 @@ impl Itemstore {
return Err(MizeError{
code: 104,
kind: "data_storage::index_not_found".to_string(),
message: "Internal Datastorage Error: the Index of the Item was not found".to_string(),
message: "Internal Datastorage Error: the Index of the Item was not found, This means most likely that this item does not exist.".to_string(),
});
}