diff --git a/Tribler/Core/Upgrade/db_upgrader.py b/Tribler/Core/Upgrade/db_upgrader.py index fea2df8097a..3a5d515259f 100644 --- a/Tribler/Core/Upgrade/db_upgrader.py +++ b/Tribler/Core/Upgrade/db_upgrader.py @@ -39,11 +39,12 @@ class DBUpgrader(object): structure from Tribler version 6.3 to 6.4. """ - def __init__(self, session, db, status_update_func=None): + def __init__(self, session, db, torrent_store, status_update_func=None): self._logger = logging.getLogger(self.__class__.__name__) self.session = session self.db = db self.status_update_func = status_update_func if status_update_func else lambda _: None + self.torrent_store = torrent_store self.failed = True self.torrent_collecting_dir = self.session.get_torrent_collecting_dir() @@ -357,13 +358,10 @@ def reimport_torrents(self): torrent_db_handler.misc_db.initialize() torrent_db_handler.category = Category.getInstance() - self.status_update_func("Opening torrent store...") - torrent_store = TorrentStore(self.session.get_torrent_store_dir()) - # TODO(emilon): It would be nice to drop the corrupted torrent data from the store as a bonus. self.status_update_func("Registering recovered torrents...") try: - for infoshash_str, torrent_data in torrent_store.itervalues(): + for infoshash_str, torrent_data in self.torrent_store.itervalues(): self.status_update_func("> %s" % infoshash_str) torrentdef = TorrentDef.load_from_memory(torrent_data) if torrentdef.is_finalized(): @@ -375,4 +373,4 @@ def reimport_torrents(self): torrent_db_handler.close() Category.delInstance() self.db.commit_now() - return torrent_store.close() + return self.torrent_store.flush()