From: Omar Polo Subject: ignore lonely packs at a lower level To: gameoftrees@openbsd.org Date: Fri, 09 Aug 2024 15:58:18 +0200 instead of having to deal with these in gotwebd, deal with the lonely pack error at a lowel level, i.e. in got_repo_search_packidx and match routines. This also makes the repo_purge_redundant_packfile skip over these lonely packs, but maybe the -p could be an implicit default behaviour of cleanup. But not in this diff :) thoughts? diff /home/op/w/got commit - 62baee9a86a9325d23bf2f048d28f38b978f707d path + /home/op/w/got blob - ea44d67c0df8c731d5a45b797add4cbee60f171c file + gotwebd/gotweb.c --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -197,7 +197,7 @@ gotweb_process_request(struct request *c) if (qs->action != INDEX) { error = gotweb_load_got_path(&repo_dir, qs->path, c); c->t->repo_dir = repo_dir; - if (error && error->code != GOT_ERR_LONELY_PACKIDX) + if (error) goto err; } @@ -825,7 +825,7 @@ gotweb_render_index(struct template *tp) error = gotweb_load_got_path(&repo_dir, sd_dent[d_i]->d_name, c); - 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); blob - f6c9b881e64ee0270d643a9dc809378060318b2b file + lib/repository.c --- lib/repository.c +++ lib/repository.c @@ -1404,8 +1404,11 @@ got_repo_search_packidx(struct got_packidx **packidx, err = got_packidx_open(packidx, got_repo_get_fd(repo), path_packidx, 0, repo->algo); - if (err) + if (err) { + if (err->code == GOT_ERR_LONELY_PACKIDX) + continue; goto done; + } err = add_packidx_bloom_filter(repo, *packidx, path_packidx); if (err) @@ -1849,8 +1852,13 @@ retry: err = got_packidx_open(&packidx, got_repo_get_fd(repo), path_packidx, 0, repo->algo); - if (err) + if (err) { + if (err->code == GOT_ERR_LONELY_PACKIDX) { + err = NULL; + continue; + } break; + } got_object_id_queue_free(&matched_ids); @@ -2598,8 +2606,13 @@ got_repo_get_packfile_info(int *npackfiles, int *nobje err = got_packidx_open(&packidx, got_repo_get_fd(repo), path_packidx, 0, repo->algo); free(path_packidx); - if (err) + if (err) { + if (err->code == GOT_ERR_LONELY_PACKIDX) { + err = NULL; + continue; + } goto done; + } if (fstat(packidx->fd, &sb) == -1) goto done; blob - 7c31b2fe91e06a2c69dab4fb449f2bf62b1e09f1 file + lib/repository_admin.c --- lib/repository_admin.c +++ lib/repository_admin.c @@ -1354,8 +1354,13 @@ repo_purge_redundant_packfiles(struct got_repository * i = 0; TAILQ_FOREACH(pe, &repo->packidx_paths, entry) { err = got_repo_get_packidx(&packidx, pe->path, repo); - if (err) + if (err) { + if (err->code != GOT_ERR_LONELY_PACKIDX) { + npacks--; + continue; + } goto done; + } pinfo = &sorted[i++]; pinfo->path = pe->path;