From 6100291b94472f5b44fa5901bedc2178a831e1ad Mon Sep 17 00:00:00 2001 From: Alexander Kozlovsky Date: Fri, 28 May 2021 14:04:51 +0200 Subject: [PATCH] Fixes #6115: Move an async function call out of the db_session scope (#6134) --- .../modules/metadata_store/gigachannel_manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tribler-core/tribler_core/modules/metadata_store/gigachannel_manager.py b/src/tribler-core/tribler_core/modules/metadata_store/gigachannel_manager.py index 58b46e94ccd..dc2b9cc9120 100644 --- a/src/tribler-core/tribler_core/modules/metadata_store/gigachannel_manager.py +++ b/src/tribler-core/tribler_core/modules/metadata_store/gigachannel_manager.py @@ -82,8 +82,11 @@ async def regenerate_channel_torrent(self, channel_pk, channel_id): if channel is None: self._logger.warning("Tried to regenerate non-existing channel %s %i", hexlify(channel_pk), channel_id) return None - for d in self.session.dlmgr.get_downloads_by_name(channel.dirname): - await self.session.dlmgr.remove_download(d, remove_content=True) + channel_dirname = channel.dirname + for d in self.session.dlmgr.get_downloads_by_name(channel_dirname): + await self.session.dlmgr.remove_download(d, remove_content=True) + with db_session: + channel = self.session.mds.ChannelMetadata.get_for_update(public_key=channel_pk, id_=channel_id) regenerated = channel.consolidate_channel_torrent() # If the user created their channel, but added no torrents to it, # the channel torrent will not be created.