Error handling
This commit is contained in:
parent
08cc0812bf
commit
f757190c3b
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1314,6 +1314,7 @@ dependencies = [
|
|||
name = "magic-nix-cache"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"attic",
|
||||
"attic-client",
|
||||
"axum",
|
||||
|
|
|
@ -29,6 +29,7 @@ attic = { git = "ssh://git@github.com/DeterminateSystems/attic-priv", branch = "
|
|||
attic-client = { git = "ssh://git@github.com/DeterminateSystems/attic-priv", branch = "main" }
|
||||
#attic-client = { path = "../../attic-priv/client" }
|
||||
indicatif = "0.17"
|
||||
anyhow = "1.0.71"
|
||||
|
||||
[dependencies.tokio]
|
||||
version = "1.28.0"
|
||||
|
|
|
@ -119,9 +119,7 @@ async fn enqueue_paths(
|
|||
.collect();
|
||||
|
||||
if let Some(flakehub_state) = &*state.flakehub_state.read().await {
|
||||
crate::flakehub::enqueue_paths(flakehub_state, store_paths)
|
||||
.await
|
||||
.unwrap();
|
||||
crate::flakehub::enqueue_paths(flakehub_state, store_paths).await?;
|
||||
}
|
||||
|
||||
Ok(Json(EnqueuePathsResponse {}))
|
||||
|
|
|
@ -27,6 +27,9 @@ pub enum Error {
|
|||
|
||||
#[error("GHA cache is disabled")]
|
||||
GHADisabled,
|
||||
|
||||
#[error("FlakeHub cache error: {0}")]
|
||||
FlakeHub(anyhow::Error),
|
||||
}
|
||||
|
||||
impl IntoResponse for Error {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::error::Result;
|
||||
use crate::error::{Error, Result};
|
||||
use attic::api::v1::cache_config::{CreateCacheRequest, KeypairConfig};
|
||||
use attic::cache::CacheSliceIdentifier;
|
||||
use attic::nix_store::{NixStore, StorePath};
|
||||
|
@ -20,8 +20,6 @@ const JWT_PREFIX: &str = "flakehub1_";
|
|||
const USER_AGENT: &str = "magic-nix-cache";
|
||||
|
||||
pub struct State {
|
||||
cache: CacheSliceIdentifier,
|
||||
|
||||
pub substituter: String,
|
||||
|
||||
pub push_session: PushSession,
|
||||
|
@ -250,14 +248,16 @@ pub async fn init_cache(
|
|||
});
|
||||
|
||||
Ok(State {
|
||||
cache,
|
||||
substituter: flakehub_cache_server.to_owned(),
|
||||
push_session,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn enqueue_paths(state: &State, store_paths: Vec<StorePath>) -> Result<()> {
|
||||
state.push_session.queue_many(store_paths).unwrap();
|
||||
state
|
||||
.push_session
|
||||
.queue_many(store_paths)
|
||||
.map_err(Error::FlakeHub)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue