aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-07-30 08:58:19 +0200
committerMartin Fischer <martin@push-f.com>2022-07-30 08:58:19 +0200
commite9532cfbf9b125db3e0d501da1b2d678713b55bb (patch)
treeb55929645fb6a6293787c258b2642f58aff4a7b7 /src/main.rs
parent8f3eafb32cb90bb9b3c1828a3f2d60a098efd5ff (diff)
fix regression: allow creation of branches
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs10
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, &params, 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()));
}