mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit 33401dee4951133fb94eed677c53a510a203ec16
parent 07ea58d2dac2620a0ae80a8d3273d4628c0101be
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Sat, 20 Mar 2021 21:46:49 +0100

check for export file in correct directory

The export directory should not be in the workdir for non-bare repos,
instead always check the git directory, i.e. the repo for bare repos or
the .git directory for non-bare repos.

Diffstat:
Msrc/main.rs | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -106,13 +106,12 @@ async fn index(_req: Request<()>) -> tide::Result { .map(|entries| { entries .filter_map(|entry| Some(entry.ok()?.path())) - .filter(|entry| { - // check for the export file - let mut path = entry.clone(); - path.push(&CONFIG.export_ok); - path.exists() - }) .filter_map(|entry| Repository::open(entry).ok()) + .filter(|repo| { + // check for the export file in the git directory + // (the .git subfolder for non-bare repos) + repo.path().join(&CONFIG.export_ok).exists() + }) .collect::<Vec<_>>() }) .map_err(|e| tide::log::warn!("can not read repositories: {}", e))