Skip to content

Commit

Permalink
Fixes #5568: DatabaseSessionIsOver: Cannot load attribute TorrentStat…
Browse files Browse the repository at this point in the history
…e[...].seeders
  • Loading branch information
kozlovsky committed Sep 23, 2020
1 parent b31f5c8 commit 93d02ec
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,19 @@ def _process_received_blob():
self.metadata_store.disconnect_thread()
return None, None

# it is incorrect to call md.simple_dict() for metadata objects from md_results
# as previous db_session is already over, so we are going to fetch them again in a new db_session
md_ids = [
md.rowid for md, action in md_results
if md
and (md.metadata_type in [CHANNEL_TORRENT, REGULAR_TORRENT])
and action in [UNKNOWN_CHANNEL, UNKNOWN_TORRENT, UPDATED_OUR_VERSION, UNKNOWN_COLLECTION]
]

with db_session:
md_list = self.metadata_store.ChannelNode.select(lambda md: md.rowid in md_ids)[:]
result = (
[
md.to_simple_dict()
for (md, action) in md_results
if (
md
and (md.metadata_type in [CHANNEL_TORRENT, REGULAR_TORRENT])
and action in [UNKNOWN_CHANNEL, UNKNOWN_TORRENT, UPDATED_OUR_VERSION, UNKNOWN_COLLECTION]
)
],
[md.to_simple_dict() for md in md_list],
gen_have_newer_results_blob(md_results),
)
self.metadata_store.disconnect_thread()
Expand Down

0 comments on commit 93d02ec

Please sign in to comment.