"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
gotwebd: stop ignoring GOT_ERR_LONELY_PACKIDX?
To:
gameoftrees@openbsd.org
Date:
Fri, 28 Apr 2023 11:30:12 +0200

Download raw body.

Thread
The subject may be a bit misleading.

In df2d3cd2545e0a1579ce83ae137e52135755ed1f I've introduced a logic
error in gotweb_render_index():

 		error = gotweb_load_got_path(c, repo_dir);
-		if (error && error->code == GOT_ERR_NOT_GIT_REPO) {
-			error = NULL;
+		if (error && error->code == GOT_ERR_LONELY_PACKIDX) {
+			if (error->code != GOT_ERR_NOT_GIT_REPO)
+				log_warnx("%s: %s: %s", __func__,
+				    sd_dent[d_i]->d_name, error->msg);
 			gotweb_free_repo_dir(repo_dir);
 			repo_dir = NULL;
 			d_skipped++;
 			continue;
 		}
-		if (error && error->code != GOT_ERR_LONELY_PACKIDX)
-			goto done;

the error->code == GOT_ERR_LONELY_PACKIDX should be !=

The result is not very grave, it "just" means that we show entries in
the repository listing that we shouldn't do, like ones that lack the
export-ok file, but that's it.  Clicking on them shows an error page.

While the fix would be really simple, just turn an == into a != and
call it a day, I was wondering why gotwebd is the only component that
explicitly ignores GOT_ERR_LONELY_PACKIDX?  Can we fail like got, tog
etc... do?


diff /home/op/w/got
commit - 76cbc7c5854f28fb476b6c80d69163c6a0796725
path + /home/op/w/got
blob - 532cb2f0f6b9415c1433f00e174bb0fd10c72992
file + gotwebd/gotweb.c
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -201,7 +201,7 @@ gotweb_process_request(struct request *c)
 			goto err;
 		error = gotweb_load_got_path(c, repo_dir);
 		c->t->repo_dir = repo_dir;
-		if (error && error->code != GOT_ERR_LONELY_PACKIDX)
+		if (error)
 			goto err;
 	}
 
@@ -865,7 +865,7 @@ gotweb_render_index(struct template *tp)
 			continue;
 
 		error = gotweb_load_got_path(c, repo_dir);
-		if (error && error->code == GOT_ERR_LONELY_PACKIDX) {
+		if (error) {
 			if (error->code != GOT_ERR_NOT_GIT_REPO)
 				log_warnx("%s: %s: %s", __func__,
 				    sd_dent[d_i]->d_name, error->msg);