commit 57cafc2c8d2cc3945d19d99980c58a2b332db572 from: Omar Polo via: Thomas Adam date: Wed Aug 14 21:51:01 2024 UTC skip over lonely packidx when searching for objects This changes the search_packidx, match_packed_object and get_packfile_info routines to skip over lonely packidx. These seems to be generated occasionally by 'git fetch' over HTTP/S. Instead of dealing with this situation in gotwebd, which is fragile, attempt to do it at the lib/ level. `gotadmin cleanup' will still complain about these lonely packidx and `gotadmin cleanup -p' is still required. discussed with and ok stsp@ commit - abda67d236225bf3dbd811ef21bbb4ee5cc776cf commit + 57cafc2c8d2cc3945d19d99980c58a2b332db572 blob - f406126feba64545994a0f2df7813d09b3fcf5b3 blob + dd5ddd66791e34aeb23a083a5a7f1b44d0072483 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -196,7 +196,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; } @@ -824,7 +824,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 - b3c25e4d161c86c2d9438b113e62c0577cd113d0 blob + 9bddd3a51e1ec80f257cfd9ed273feb7625ab9c3 --- lib/repository.c +++ lib/repository.c @@ -1400,8 +1400,13 @@ 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) { + err = NULL; + continue; + } goto done; + } err = add_packidx_bloom_filter(repo, *packidx, path_packidx); if (err) @@ -1846,8 +1851,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); @@ -2596,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;