diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 8f756ef..73de77d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,14 +367,14 @@ async fn build_response<C: Controller>( return post_routes::build_response(origin, ¶ms, controller, ctx, body, parts).await; } - let tree = ctx.branch_head()?.tree(); + let tree = ctx.branch_head().ok().and_then(|c| c.tree().ok()); if ctx.path.components().next().is_none() { return get_routes::view_tree(tree, controller, &ctx, parts); } - match tree.and_then(|t| t.get_path(ctx.path.as_ref())) { - Ok(entr) => match entr.kind().unwrap() { + match tree.and_then(|t| t.get_path(ctx.path.as_ref()).ok()) { + Some(entr) => match entr.kind().unwrap() { ObjectType::Blob => { if unsanitized_path.ends_with('/') { return Ok(Builder::new() @@ -396,11 +396,11 @@ async fn build_response<C: Controller>( if !unsanitized_path.ends_with('/') { return Err(Error::MissingTrailingSlash(parts.uri.path().to_owned())); } - get_routes::view_tree(ctx.repo.find_tree(entr.id()), controller, &ctx, parts) + get_routes::view_tree(ctx.repo.find_tree(entr.id()).ok(), controller, &ctx, parts) } _other => panic!("unexpected object type"), }, - Err(_) => { + None => { if unsanitized_path.ends_with('/') { return Err(Error::NotFound("directory not found".into())); } |