Don't crash if the client sends an invalid store path name
This commit is contained in:
parent
1835ad1c08
commit
de2b44169c
|
@ -9,7 +9,7 @@ use axum_macros::debug_handler;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::State;
|
use super::State;
|
||||||
use crate::error::Result;
|
use crate::error::{Error, Result};
|
||||||
use crate::util::{get_store_paths, upload_paths};
|
use crate::util::{get_store_paths, upload_paths};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
@ -112,11 +112,11 @@ async fn enqueue_paths(
|
||||||
) -> Result<Json<EnqueuePathsResponse>> {
|
) -> Result<Json<EnqueuePathsResponse>> {
|
||||||
tracing::info!("Enqueueing {:?}", req.store_paths);
|
tracing::info!("Enqueueing {:?}", req.store_paths);
|
||||||
|
|
||||||
let store_paths: Vec<_> = req
|
let store_paths = req
|
||||||
.store_paths
|
.store_paths
|
||||||
.iter()
|
.iter()
|
||||||
.map(|path| state.store.follow_store_path(path).unwrap())
|
.map(|path| state.store.follow_store_path(path).map_err(Error::Attic))
|
||||||
.collect();
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
|
||||||
if let Some(flakehub_state) = &*state.flakehub_state.read().await {
|
if let Some(flakehub_state) = &*state.flakehub_state.read().await {
|
||||||
crate::flakehub::enqueue_paths(flakehub_state, store_paths).await?;
|
crate::flakehub::enqueue_paths(flakehub_state, store_paths).await?;
|
||||||
|
|
|
@ -345,8 +345,9 @@ async fn post_build_hook(out_paths: &str) {
|
||||||
match response {
|
match response {
|
||||||
Ok(response) if !response.status().is_success() => {
|
Ok(response) if !response.status().is_success() => {
|
||||||
err_message = Some(format!(
|
err_message = Some(format!(
|
||||||
"magic-nix-cache server failed to enqueue the push request: {}",
|
"magic-nix-cache server failed to enqueue the push request: {}\n{}",
|
||||||
response.status()
|
response.status(),
|
||||||
|
response.text().await.unwrap_or_else(|_| "".to_owned()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
|
|
Loading…
Reference in a new issue