prevent sqlite database from locking up

This commit is contained in:
Izalia Mae 2024-02-15 20:26:33 -05:00
parent b86159c7ae
commit b259f2d760

View file

@ -98,6 +98,7 @@ async def handle_follow(view: ActorView, conn: Connection) -> None:
logging.verbose('Non-application actor tried to follow: %s', view.actor.id) logging.verbose('Non-application actor tried to follow: %s', view.actor.id)
return return
with conn.transaction():
if conn.get_inbox(view.actor.shared_inbox): if conn.get_inbox(view.actor.shared_inbox):
view.instance = conn.update_inbox(view.actor.shared_inbox, followid = view.message.id) view.instance = conn.update_inbox(view.actor.shared_inbox, followid = view.message.id)
@ -144,6 +145,7 @@ async def handle_undo(view: ActorView, conn: Connection) -> None:
if view.instance['followid'] and view.instance['followid'] != view.message.object_id: if view.instance['followid'] and view.instance['followid'] != view.message.object_id:
return return
with conn.transaction():
if not conn.del_inbox(view.actor.id): if not conn.del_inbox(view.actor.id):
logging.verbose( logging.verbose(
'Failed to delete "%s" with follow ID "%s"', 'Failed to delete "%s" with follow ID "%s"',
@ -182,16 +184,18 @@ async def run_processor(view: ActorView) -> None:
return return
with view.database.connection(True) as conn: with view.database.connection(False) as conn:
if view.instance: if view.instance:
if not view.instance['software']: if not view.instance['software']:
if (nodeinfo := await view.client.fetch_nodeinfo(view.instance['domain'])): if (nodeinfo := await view.client.fetch_nodeinfo(view.instance['domain'])):
with conn.transaction():
view.instance = conn.update_inbox( view.instance = conn.update_inbox(
view.instance['inbox'], view.instance['inbox'],
software = nodeinfo.sw_name software = nodeinfo.sw_name
) )
if not view.instance['actor']: if not view.instance['actor']:
with conn.transaction():
view.instance = conn.update_inbox( view.instance = conn.update_inbox(
view.instance['inbox'], view.instance['inbox'],
actor = view.actor.id actor = view.actor.id