ostree icon indicating copy to clipboard operation
ostree copied to clipboard

api: make transactions autocleanups public

Open lucab opened this issue 4 years ago • 4 comments

From the code review at https://github.com/ostreedev/ostree/pull/2411#discussion_r690416686:

I think we can push this forward into fully using autocleanups with _ostree_repo_auto_transaction_start (repo, cancellable, error);?

Oh I see, that's private API. Blah. Probably time to make it public.

lucab avatar Aug 18 '21 08:08 lucab

Side note: I think this one needs to be manually bound in Rust, unless we make it a boxed type.

cgwalters avatar Aug 25 '21 16:08 cgwalters

Regarding this logic, https://github.com/ostreedev/ostree-rs/pull/33/files sketches an alternative/different implementation (which I think I'm liking more than status quo) along the following lines:

  • a dedicated internal repo reference, nullable
  • explicit commit/abort methods which do consume the guard
  • auto-cleanup logic which only triggers an abort call if the guard as not been consumed (via explicit commit/abort) before

lucab avatar Sep 29 '21 16:09 lucab

I made a pass on this and ported back some of the enhancements from the Rust side, PR at https://github.com/ostreedev/ostree/pull/2454.

I also looked into moving this guard to a gobject boxed type. I admit my shallow knowledge in this area, so please correct me if here below I'm making any wrong statements.

I think that in this specific case OstreeRepoAutoTransaction cannot be expressed as a boxed type due to semantic mismatches. In particular, it is my understanding that a boxed type is primarily meant for type-values that can be (trivially) copied, and thus requires a mandatory non-nullable GBoxedCopyFunc. In our case instead OstreeRepoAutoTransaction is a guard which enforces scope/ownership, so I think we won't actually expose a way to duplicate an existing guard.

lucab avatar Oct 05 '21 12:10 lucab

From an out-of-band chat, it would still be preferable to have auto-generated bindings for this. Going back to a boxed type for this, we can add internal reference counting to OstreeRepoAutoTransaction so that copy/free functions can operate on light references, while still keeping a single guard underneath.

lucab avatar Oct 08 '21 14:10 lucab