fix(iroh-docs): Add flush_store
and use it to make sure the default author is persisted
#2471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
flush_store
function to the docs actor/handledocs_store.flush_store().await?
before persisting the default author ID fileThere's two pieces of data related to the default author:
The code to store these two pieces of data looked like this:
So it would look like we make sure the author is stored before we store the file (which is basically just a reference to the author in the DB).
However,
import_author
is somewhat lazy, because it batches operations together in a bigger transaction.The store would actually only get flushed in e.g.
shutdown
. So most of the time, the actual persisting of the author would happen after the call toself.persist
.If you wait for
shutdown
every time, it's all good, because that'll callflush
. If not, then there will be some issues.The fix in this PR is to introduce a
flush_store
function so we can use it afterimport_author
to make sure it's actually flushed before weself.persist(author_id)
.Breaking Changes
None. Only an addition:
iroh-docs::actor::SyncHandle::flush_store
.Notes & open questions
There might still be something wrong with
shutdown
not running correctly, but IMO this is an improvement regardless.Closes #2462
Change checklist
[ ] Tests if relevant.