Re: [PATCH v2 08/24] midx: respect 'core.multiPackIndex' when writing
- From
Jeff King <peff@peff.net>
- Date
- Jul 27, 2021, 17:42 UTC
- Message-ID
- <YQBFi70c1wfXdKQf@coredump.intra.peff.net>
- In-Reply-To
- <YQBEIrRfcq5dhpZn@nand.local>
On Tue, Jul 27, 2021 at 01:36:34PM -0400, Taylor Blau wrote:
Show 15 quoted lines
> > But now the internal midx writing code can never call close_midx() on > > that, because it does not own it to close. Can we simply drop the > > close_midx() call there? > > > > This would all make much more sense to me if write_midx_internal() > > simply took a conceptually read-only midx as a parameter, and the caller > > passed in the appropriate one (probably even using > > prepare_multi_pack_index_one() to get it). > > No, we can't drop the close_midx() call there because we must close the > MIDX file on Windows before moving a new one into place. My feeling is > we should always be working on the r->objects->multi_pack_index pointer, > and calling close_object_store() there instead of close_midx(). > > Does that seem like a reasonable approach to you?
Yes, though I'd have said that it is the responsibility of the caller (who knows we are operating with r->objects->multi_pack_index) to do that closing. But maybe it's not possible if the rename-into-place happens at too low a level.
BTW, yet another weirdness: close_object_store() will call close_midx() on the outermost midx struct, ignoring o->multi_pack_index->next entirely. So that's a leak, but also means we may not be closing the midx we're interested in (since write_midx_internal() takes an object-dir parameter, and we could be pointing to some other object-dir's midx).
-Peff