From 73b5e2fee5e9490ec146b05322b45c7d8bb9ee46 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Wed, 24 Jan 2024 20:34:13 +0100 Subject: Properly handle private repos --- server/src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/src/main.rs b/server/src/main.rs index 0f12c8f..2df42dd 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -740,6 +740,7 @@ fn forwarded_from_trusted_host( } Ok(false) } + const REPO_NOT_FOUND: GitLfsErrorResponse = make_error_resp(StatusCode::NOT_FOUND, "Repository not found"); @@ -796,10 +797,11 @@ fn is_repo_public(name: &str) -> Option { if !repo_exists(name) { return None; } - std::fs::metadata(format!("{name}/git-daemon-export-ok")) - .ok()? - .is_file() - .into() + match std::fs::metadata(format!("{name}/git-daemon-export-ok")) { + Ok(metadata) if metadata.is_file() => Some(true), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => Some(false), + _ => None, + } } async fn batch( -- cgit v1.2.3